Note that there are some explanatory texts on larger screens.

plurals
  1. POgetBitmap from SQLite to ListView
    text
    copied!<p>I'm trying to show profile <code>Contact</code> image from <code>SQLite</code> on android app but it doesn't work and it crashes on <code>image.setImageBitmap(bitmap)</code> that appears <code>.NullPointerException</code> and I don't Know why.</p> <p>If someone can help me please. this is my code:</p> <pre><code>public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); DatabaseHandler helper = new DatabaseHandler(this); database = helper.getWritableDatabase(); Cursor data = database.query("amigos", fields, null, null, null, null, null); data.moveToFirst(); dataSource = new SimpleCursorAdapter(this, R.layout.row_def, data, fields, new int[] {R.id.Nombre_Amigo, R.id.profile_picture}); Log.d("ListarContactos","Oncreate....data: "+data.toString()); while (!data.isAfterLast()){ byte[] bb = data.getBlob(data.getColumnIndex(DatabaseHandler.KEY_PIC_SQ)); Log.d("ListarContactos","Oncreate....bb: "+bb.toString()); ByteArrayInputStream inputStream = new ByteArrayInputStream(bb); Log.d("ListarContactos","Oncreate....inputStream: "+inputStream.toString()); Bitmap bitmap = BitmapFactory.decodeByteArray(bb, 0, bb.length); Log.d("ListarContactos","Oncreate....Bitmap: "+bitmap.toString()); ImageView image = (ImageView) findViewById(R.id.profile_picture); image.setImageBitmap(bitmap); Log.d("ListarContactos","Oncreate....image: "+image.toString()); } Log.d("ListarContactos","Oncreate....datasource: "+dataSource.toString()); setListAdapter(dataSource); Log.d("ListarContactos","Oncreate....despres del ListAdapter"); helper.close(); ListView view = getListView(); } </code></pre>
 

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