Skip to content Skip to sidebar Skip to footer

Loading Dynamic Images From Sqlite

I returned a string from SQLite table and want to load image from the drawable folder. Is it possible? For example : String name = sql.getName(1); //name is now Barney img.setImage

Solution 1:

1st. A few weeks ago i used this for a VideoView. Must be nearly the same for pictures.

In my place i stored the videos in the /raw folder.

mVideoView.setVideoPath("android.resource://your-package-name/raw/"+videoName);

2nd. Why don't you save the picture into the database and read it from there? like this:

byte[] blob = cursor.getBlob(2);

Solution 2:

Ah, I've found it.

Stringimage="test";
intpimageid= getResources().getIdentifier("com.yourpackage.name:drawable/"+image,null,null);
img.setImageResource(pimageid);

Post a Comment for "Loading Dynamic Images From Sqlite"