vendredi 27 mars 2015

Android: Thumbnail stored in DB is returned null

I have a Db where I have stored the path of a video and its thumbnail in ByteArray form. But when I try to retrieve the thumbnail from the DB I always get null value. Here is the code I am using to retrieve both the thumb and the path:



db=openOrCreateDatabase("VideoPaths", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS paths(path VARCHAR,thumbnail BLOB);");
Cursor c = db.rawQuery("SELECT path,thumbnail FROM paths",null);
int index = c.getColumnIndex("path");
int index2 = c.getColumnIndex("thumbnail");

c.moveToFirst();

if (c != null) {
// Loop through all Results
do {

String VideoPath = c.getString(index);
byte[] bytes = c.getBlob(index2);
Bitmap thumb = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);


pathList.add(VideoPath);
listRow.add(new VideoRow(VideoPath,thumb, "User", "Testing"));

} while (c.moveToNext());
}


Do you have any ideas on how to fix this issue ?


P.S The video path retrieval is working fine.


Aucun commentaire:

Enregistrer un commentaire