Android 单击其他图像时如何从sqlite检索图像
我创建的sqlite数据库包含两个图像。我想显示一个图像。然后,当我在图像中单击时,我将显示存储在sqlite数据库中的第二个图像 我的采用者方法Android 单击其他图像时如何从sqlite检索图像,android,image,sqlite,android-imageview,android-gridview,Android,Image,Sqlite,Android Imageview,Android Gridview,我创建的sqlite数据库包含两个图像。我想显示一个图像。然后,当我在图像中单击时,我将显示存储在sqlite数据库中的第二个图像 我的采用者方法 public Bitmap getMemorie(int id){ SQLiteDatabase db = getWritableDatabase(); String enc = "data:image/png;base64"; Cursor cursor = db.rawQuery("sel
public Bitmap getMemorie(int id){
SQLiteDatabase db = getWritableDatabase();
String enc = "data:image/png;base64";
Cursor cursor = db.rawQuery("select * from memories where _id=?",new String[]{String.valueOf(id)});
if(cursor.moveToNext()){
enc = String.valueOf(cursor.getColumnIndex(MemoryContract.MemoryEntry.COLUMN_LOGO));
}
String pure=enc.substring(enc.indexOf(",")+1);
byte[] encodeByte = Base64.decode(pure,Base64.DEFAULT);
Bitmap decodeByte = BitmapFactory.decodeByteArray(encodeByte,0,encodeByte.length);
返回解码字节;
}
我的活动
Intent intent =getIntent();
//getting extras which are sent from first activity
int myposition=intent.getExtras().getInt("id");
Log.d("h", "the cat is " + myposition);
//Cursor data = dbHelper.getMemorie("select * from memories where _id= ?",+myposition);
this.dbHelper = new MemoryDbHelper(this);
this.imageview.setImageBitmap(dbHelper.getMemorie(myposition));
我得到一个错误:
bad base64 java.lang.IllegalArgumentException:bad base-64
谢谢您是否在一行一列中保存了两张图像?(是的,那么您使用了哪种分割器?)您可以记录(品脱)第一幅图像和第二幅图像的结果吗?