-1

When I try to get data from SQlite and size of field more than 2 MB it throw exception

"Couldn't read row 0, col 0 from Cursor Window. Make sure the Cursor is initialized correctly before accessing data from it."

How can I store a field that have above 2 Mb get into string ?

i store multiple Base64 Strings as LONG TEXT in sqlite it store successfully but when i fatch from database that goes into exception because of that field contain above 2400000 characters.

this is the code

public ArrayList<HashMap<String, String>> selectRecordFromDbList(String qry, String[] args, boolean status) {
        ArrayList<HashMap<String, String>> arraylist = null;
        try {
            HashMap<String, String> mapRow;
            Cursor cursor = sqLiteDatabase.rawQuery(qry, args);
            if (cursor.moveToFirst()) {
                arraylist = new ArrayList<>();
                do {
                    mapRow = new HashMap<>();
                    for (int i = 0; i < cursor.getColumnCount(); i++) {
                        mapRow.put(cursor.getColumnName(i), cursor.getString(i));
                    }
                    arraylist.add(mapRow);
                } while (cursor.moveToNext());
            }
            if (cursor != null && cursor.isClosed()) {
                cursor.close();
            }
        } catch (Exception e) {
            Log.e("SqliteAssetHelper:", e.getMessage());
            arraylist = null;

        }
        return arraylist;
    }
Jai Khambhayta
  • 4,198
  • 2
  • 22
  • 29

1 Answers1

0

It is not advisable to store large BLOBS or similar data in the SQLite database. You should use the file system and only store a reference to the data in you database. Refer to this answer

Frederick Nyawaya
  • 2,285
  • 1
  • 15
  • 19
  • This is what I will do, but until save the file, I need to download the chunks. Some idea of how this should be done? – IgniteCoders Apr 05 '18 at 12:15