Here is what I did:
I created an column (blob type) and saved successfully the byte array into it. Then I got the image by this code:
cursor.moveToFirst();
theme = cursor.getBlob(cursor.getColumnIndex("Theme"));
bitmap = BitmapFactory.decodeByteArray(theme, 0, theme.length);
screenBackGround.setBackground(new BitmapDrawable(getResources(), bitmap));
- NOTE: There is just 1 row.
At 1st try:
- I used an 500x500 (12.6KB) image and it worked.
Then 2nd try:
-
I used an 768x1280 (120KB) image and then I got this error:
12-24 06:24:54.965: E/CursorWindow(1186): Failed to read row 0, column 1 from a CursorWindow which has 0 rows, 3 columns.
12-24 06:24:54.965: E/AndroidRuntime(1186): java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
I don't know why I get this exception, I thought there should be OutOfMemory exception or sth, please explain to me and teach me how to fix that. Thank you!
Aucun commentaire:
Enregistrer un commentaire