Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying image from database in listview
    primarykey
    data
    text
    <p>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:</p> <pre><code>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(); </code></pre> <p>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</p> <p>Edit: If anyone can post how to get only the values of "App_icon" column from all the rows and store it in an array? That would be helppful</p> <p>Edit 2: Below is the method used to get the image</p> <pre><code>adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue (View view, Cursor cursor, int columnIndex){ if (view.getId() == R.id.app_icon) { ImageView IV=(ImageView) view; Bitmap icon; BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; byte[] image = null; Cursor images = mySQLiteAdapter.geticon(); int rows = images.getCount(); for(int i=1;i&lt;=rows;i++){ image = mySQLiteAdapter.getIcon(i); icon = BitmapFactory.decodeByteArray(image , 0, image .length, options); Toast.makeText(getActivity(), "executes"+rows, Toast.LENGTH_SHORT).show(); IV.setImageBitmap(icon); } //IV.setBackgroundColor(Color.TRANSPARENT); return true; } return false; } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload