How to retrieve an image stored in Sqlite table?
the table looks like the following:
public class ImageInDB extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final String DATABASE_NAME = "test01.db";
private static final String MP_TABLE_NAME = "MPImage";
ImageInDB (Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}// end of
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(" CREATE TABLE " + MP_TABLE_NAME + " ( " +
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
" img BLOB " +
");" );
}
Now, how should the method that retrieve the image llok like?? below is my attempt:
public ??? getMP_RPY(long id) {
SQLiteDatabase db = this.getReadableDatabase();
SQLiteCursor c = (SQLiteCursor) db.rawQuery("SELECT img FROM MPImage WHERE "+
BaseColumns._ID+" = "+
Long.toString(id), null);
c.moveToFirst();
???? r = c.getDouble(0);
return r;
}
OR
Please check this link