@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + INFR_TABLE
+ "(_id INTEGER PRIMARY KEY NOT NULL," + CATEGORY + " integer,"
+ STATUS + " text, " + FEEDBACK + " text, " + DATE + " text, "
+ IMAGE + " BLOB)");
System.out.println("Database Createeeeeeeeeeeeeee");
}
public byte getimage( String id)
{
db = this.getReadableDatabase();
cursor = db.query(INFR_TABLE, new String[] { "_id", "cateogry",
"status", "feedback", "date", "image" }, null, null, null,
null, null);
return 0;
}
我将数据库中的图像保存为Blob,我想基于id获取特定的图像,但是我无法在字节中获取它,因为我必须在图像视图中打印它请帮我怎样根据id从数据库中获取图像。
答案 0 :(得分:2)
public byte[] getimage(String id)
{
db = this.getReadableDatabase();
cursor = db.query(INFR_TABLE, new String[] { "_id", "cateogry",
"status", "feedback", "date", "image" }, ID + "=?",
new String[] { String.valueOf(id) }, null, null, null, null);
cursor.moveToFirst();
byteImage2 = cursor.getBlob(cursor.getColumnIndex("image"));
// setImage(byteImage2);
cursor.close();
return byteImage2;
}
请添加此代码并享受.........如果有任何查询更新我