vendredi 31 juillet 2015

blob data not set as bitmap on imageview android

i have insert blob data in to sqlite and retrive from sqlite that time blob data not set as bitmap on imageview. give msg to fail to load. so please help me for my code. following are my code.

            bitmap = android.provider.MediaStore.Images.Media
             .getBitmap(cr, selectedImage);

            imageView.setImageBitmap(bitmap);


            ByteArrayOutputStream stream= new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte imginbyte[]=stream.toByteArray();
            byte temp[]=imginbyte;

            myDb.execSQL("INSERT INTO tableimage VALUES('"+temp+"');");
            Cursor c= myDb.rawQuery("SELECT * FROM tableimage", null);
            c.moveToLast();
            byte asd[]= c.getBlob(c.getColumnIndex("imgpath"));
            byte img[]=null;

          //  BitmapFactory.decodeByteArray(asd, 0, asd.length);
            ImageView iv=(ImageView)findViewById(R.id.img2);
            ImageView iv1=(ImageView)findViewById(R.id.img3);

            iv.setImageBitmap( BitmapFactory.decodeByteArray(asd, 0, asd.length));
            iv1.setImageBitmap( BitmapFactory.decodeByteArray(asd, 0, asd.length));

Aucun commentaire:

Enregistrer un commentaire