0

I have a usecase in sqlite android , where in i have huge text in android api response and it is store properly in android sqlite field name image

The text is stored properly in sqlite since sqlite says TEXT field can store very very long text

Blocker :

When it comes to retrival of that text filed then i hv used below code snippet :

 questionModel.setImageBuffer(new StringBuffer(imgData == null ? "" : 

    (questionCursor.getString(questionCursor.getColumnIndex(Constants.COLUMN_QUESTION_IMAGE)))));

basically this wraps content in string and hence it does not fit into string and content is broken

Anyone can suggest me how to properly fetch that field into StringBuffer variable

Edit :

Just look over the image attached below the text is store full and its size is also displayed in sqlite browser , i hv extracted that db and verified it.

enter image description here

Maddy
  • 4,525
  • 4
  • 33
  • 53
KOTIOS
  • 11,177
  • 3
  • 39
  • 66
  • Are you sure that the text in SQLITE is stored full, not cut? The column size is not unlimited, I think you have to specify it when creating the table – Vladyslav Matviienko Feb 07 '18 at 08:37
  • @VladMatvienko Please see edited image , i m 100% sure text is complete in db – KOTIOS Feb 07 '18 at 08:39
  • I didn't find any effective limitations of SQLITE or Java's String, or anything related to them in the internet. So I don't think that there is some kind of limitation. Try splitting your complex code into different lines and steps, and check on which line it does wrong at least. – Vladyslav Matviienko Feb 07 '18 at 08:51
  • @VladMatvienko just chk String data type limit hence when i get text from cursor then it wraps it in String datatype and hence string breaks – KOTIOS Feb 07 '18 at 08:53
  • @VladMatvienko when using `SQLiteCursor` the limit is `CursorWindow` used by this class which has size of 2M if i remember correctly – pskink Feb 07 '18 at 08:54
  • I have already checked it, and it is something like 2 bil. chars for the String – Vladyslav Matviienko Feb 07 '18 at 08:54

1 Answers1

0

One solution would be to store the text as a file and save the path rather than the text in the database.

The cause is that there is a limitation (1Mb) according to Cursor size limit in Android SQLiteDatabase.

Which in one post points to :-

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size. TransactionTooLargeException

However according to this later post the limit is 2MB per row. SQLite CursorWindow limit - How to avoid crash

MikeT
  • 51,415
  • 16
  • 49
  • 68