Reputation: 373
anyone knows how to set the image from drawable folder to imageview using the path of the image from sqlite database? Any help will be appreciated. Sample codes will be helpful. Thanks. =)
Upvotes: 0
Views: 1209
Reputation: 15
ImageView imageView = (ImageView) findViewById(R.id.imageView);
String test = "imageName"; // store only image name in database(means not store "R.drawable.image") like "image".
int id = getResources().getIdentifier("projectPackageName:drawable/" + test, null, null);
imageView.setImageResource(id);
Upvotes: 1
Reputation: 520
You can get Bitmap object from file,and use it to set your image view. Here code:
String img_path = get from your database
...
Bitmap bmp = BitmapFactory.decodeFile(img_path);
//use it.
yourimgview.setImageBitmap(bmp);
^_^
Upvotes: 0