Displaying image from database in listview
So I have a table named apps with 4 columns and a column named App_icon in
which I convert the drawable to byte[] and store it in the colum
"App_icon" as blob. I have a listview where it picks up the fields from
the table as shows it. I need to also show the image at the left corner by
converting back the blob to image.The code I use to retrieve the text data
from the db and to display is:
mySQLiteAdapter.open();
String[] arrayColumns = new String[] { Dbhelper.KEY_PKG,
Dbhelper.KEY_APP, };
int[] arrayViewIDs = new int[] { R.id.appname, R.id.pkgname };
cursor = mySQLiteAdapter.getAllFolders();
adapter = new SimpleCursorAdapter(
getActivity().getApplicationContext(), R.layout.listview_items,
cursor, arrayColumns, arrayViewIDs);
lv.setAdapter(adapter);
mySQLiteAdapter.close();
Where KEY_PKG and KEY_APP are the other table names which is displayed in
textview (appname and pkgname). Could someone provide a sample code on how
to bind the image to the respective fields? Regards, Vijai
No comments:
Post a Comment