如何检索存储在Sqlite表中的图像?
该表如下所示:
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 " +
");" );
}
现在,如何检索图像llok的方法??下面是我的尝试:
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;
}
2条答案
按热度按时间xt0899hw1#
不要将图片存储到SQLite数据库中,而是存储图片的路径。或者如果您真的想将图片存储到数据库中,请学习基本的SQ Lite。
hts6caw32#
或
请检查this link