Contact
Androidアプリでプロフィール画像を表示しようとしていますが、機能せず、表示SQLite
されたときにクラッシュします。理由はわかりません。image.setImageBitmap(bitmap)
.NullPointerException
誰かが私を助けてくれるなら。これは私のコードです:
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();
}