Couldn't read row 0, col 0 from CursorWindow.

101 Views Asked by At

I'm using Sqlite database to store image and using Cursor Loader to load image int o the Screen from the database.

But I'm getting this error :

"java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it."

When ever I'm trying to insert more than 1 or 2 image into the database My Cursor Adapter Class

     ImageView imageView = view.findViewById(R.id.item_image);
    TextView textView = view.findViewById(R.id.item_name);

    //Fetching the values from the cursor
    String name = cursor.getString(cursor.getColumnIndex(ItemEntry.COLUMN_NAME));
    byte[] image = cursor.getBlob(cursor.getColumnIndex(ItemEntry.COLUMN_IMAGE));


    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    options.inSampleSize = calculateInSampleSize(options, 500, 500);
    options.inJustDecodeBounds = false;
    Bitmap imageBitmap = BitmapFactory.decodeByteArray(image, 0, image.length, options);

    //Populate the views
    imageView.setImageBitmap(imageBitmap);
    textView.setText(name);
0

There are 0 best solutions below