Note that there are some explanatory texts on larger screens.

plurals
  1. POImage not displayed in an imageView after converting a blob to bitmap
    primarykey
    data
    text
    <p>As I mentioned in the title my image is not displayed in the imageView. I have included a title and description along with the image and both are displayed properly in textViews. </p> <pre><code> // RetrieveImage(); if(databaseExists()){ displayToast("Database exists"); db = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READONLY); if(db != null){ c = db.rawQuery("SELECT image,title,description FROM Images WHERE _Id =?",new String[]{"1"},null); if (c != null ) { if(c.moveToFirst()){ img = c.getBlob(1); title = c.getString(1); description = c.getString(1); txt1.setText(title); txt2.setText(title); ByteArrayInputStream imageStream=ByteArrayInputStream(img); Bitmap bm = BitmapFactory.decodeStream(imageStream); imgView.setImageBitmap(bm); }}} </code></pre> <p>I know it would be a simple mistake but please help me to detect that mistake. </p> <p>Edit: I have attached the code snippet which insert image to database</p> <pre><code> yourSelectedImage = BitmapFactory.decodeFile(filePath); ImageView img1 = (ImageView) findViewById(R.id.imageView1); img1.setImageBitmap(yourSelectedImage); ByteArrayOutputStream bos=new ByteArrayOutputStream(); yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 100, bos); img =bos.toByteArray(); private void handleDB() { try { String myPath = DB_PATH + DATABASE_NAME; //open database in read and write mode checkDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE); if(checkDB!=null){ ContentValues contentValues = new ContentValues(); contentValues.put("myid", myId ); contentValues.put("image", img); contentValues.put("title", caption); contentValues.put("description", description); database.insert("Images", null,contentValues); } } catch(SQLiteException se ){ Log.e(getClass().getSimpleName(), "Could not create or Open the database"); } } public void createDBFields(){ database = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null); database.execSQL("CREATE TABLE IF NOT EXISTS Images ( _id INTEGER PRIMARY KEY, "+"myid nvarchar(50)," +"image BLOB," + "title nvarchar(50)," + "description nvarchar(50));"); }//createDBFields close </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload