I made a list to display all the images I captured with their details. When I choose a list item opens a new screen with delete and edit option. When i choose to delete the item my app crashes.
In the logcat displays thiw message:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
and points this code :
ImageView iv_photo = (ImageView) findViewById(R.id.cloth_image);
iv_photo.setImageBitmap(BitmapFactory.decodeFile(extras.getString("photograph")));
In the database the delete method is :
public Boolean deleteCloth(int id) {
SQLiteDatabase db = this.getWritableDatabase();
int i = db.delete(SQLITE_TABLE, KEY_ROWID + " = ?", new String[]{String.valueOf(id)});
db.close();
if (i != 0) {
return true;
} else {
return false;
}
}
I don't know what to do to fix it! Any help?
It's because the "extras" bundle is null. Investigate why is it so. Maybe your have not initialised it.