0

I've tried to find any reference about using sqlite4java in android, but the tutorial looks like so scrimpy,

I've tried with this code, but no luck

public void test4java(){
        SQLiteConnection sqLiteConnection=null;
        SQLiteStatement sqLiteStatement=null;
        Context context;
        try
        {
            File databaseFile = context.getDatabasePath("SendingData.db");
            sqLiteConnection=new SQLiteConnection(databaseFile);
            sqLiteConnection.open();
            sqLiteStatement=sqLiteConnection.prepare("SELECT * from Api");
            sqLiteStatement.bind(1, id);
            sqLiteStatement.step();
            byte[] blob=sqLiteStatement.columnBlob(0);
            Log.i("blob sqlite4java", Arrays.toString(blob));
        } catch (SQLiteException e) {
            e.printStackTrace();
        } finally
        {
            if(sqLiteStatement!=null)
                sqLiteStatement.dispose();
            if(sqLiteConnection!=null)
                sqLiteConnection.dispose();
        }
    }

there's another way about fetching blob over 2mb in sqlite?

I just think why sqlite can store blob till 1GB, but need less than 2MB to fetching?

flix
  • 1,688
  • 3
  • 34
  • 64

1 Answers1

1

Probably the most practical way to do this is to not store the image but to store the path to the image, retrieve the path and then get the image via the path when the image is required.

I guess that you could split the byte array into smaller chunks/packets which would then fit into a Cursor. However, then you'd have to manage handling the chunks and reconstructing the image.

The reason why you can store the Blob is that a Cursor is not involved when inserting a row. However, retrieval is via a Cursor which has the size restriction.

MikeT
  • 51,415
  • 16
  • 49
  • 68