单击另一个图像时如何从sqlite检索图像

问题描述

我创建的 sqlite 数据库包含两个图像。我想显示一张图片。然后,当我点击图像时,我会显示存储在 sqlite 数据库中的第二个图像。图像存储为字符串。

我的采用者方法

 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,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));

我有错误

错误的 base64 java.lang.IllegalArgumentException: 错误的 base-64

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...