如何获取以BLOB格式存储在数据库中的图像的URL

问题描述:

我正在将图像保存到wamp数据库中。如何获得它的URL,以便我可以在我的android程序中使用该URL来显示该图像?如何获取以BLOB格式存储在数据库中的图像的URL

+0

http://stackoverflow.com/a/29167261/5599807 – user5599807

public Bitmap getCurrentBitmap() { 
     SQLiteDatabase db  = dbs.getWritableDatabase(); 
     String sql    = "SELECT * FROM Image";// SELECT blob image column. 
     Cursor cursor   = db.rawQuery(sql, new String[]{}); 
     Bitmap bmp=null; 
     if(cursor.moveToFirst()){ 
      //this.accId    = cursor.getInt(0); 
      // this.accName   = cursor.getString(1); 
      byte[] logoImage  = cursor.getBlob(1);// get blob image convert into byte array[] 

     Bitmap bmp = BitmapFactory.decodeByteArray(logoImage, 0, logoImage.length);// now convert into Bitmap 
     } 
     if (cursor != null && !cursor.isClosed()) { 
      cursor.close(); 
     } 
     db.close(); 
     if(cursor.getCount() == 0){ 
      return null; 
     } else { 
      return bmp; 
     } 
    } 

//显示图片

profile_images.setImageBitmap(getCurrentBitmap()); 
+0

但我的数据库是瓦帕服务器。我刚接触android,并刚刚学习它。所以你可以根据这个编辑代码。 –

为什么会有一个网址?没有网址可以从数据库中检索内容。由于没有网址可以放入内容,因此只有脚本可以做到这一点。

那么,如果你有一个脚本来检索内容,那么你就会知道它的网址我想