Here I am attaching code in which store image in Drawable and pass to Database with BLOB Datatype.
I try this, it store properly but not display image.
Insall_app_db i1 = new Insall_app_db();
i1.createDatabse(DB, getBaseContext());
i1.createTable(tableName, getBaseContext());
BitmapDrawable bitDw = ((BitmapDrawable) icon);
Bitmap bitmap = bitDw.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
String iconStr = imageInByte.toString();
i1.insertDataUser(tableName,appid,appname2,pname, versionName, versionCode,iconStr, long_date);
int appid = i1.GetUserData(getBaseContext(), tableName);
System.out.println("-------------------------------");
byte[] imaaa = iconStr.getBytes();
Bitmap aaa = convertByteArrayToBitmap(imaaa);
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon,null);
TextView tv = (TextView)v.findViewById(R.id.icon_text);
tv.setText(i1.app_name);
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(R.drawable.icon);
Bitmap bitmap2 = ((BitmapDrawable)icon).getBitmap();
iv.setImageBitmap(aaa);
Is there any other solution to do this thing?
To get the image from the sqlite database i used the following:
Then to display the image i used to do the following:
The code below shows how to save the image into a BLOB field
the bytes can be added to sqlite using