I have a code:
public String getNameUpdateEvent(long id) {
Cursor mCursor =
db.rawQuery("select name from events WHERE _id=" + id + ";", null);
if (mCursor != null) {
mCursor.moveToFirst();
}
String updateNameEvent;
updateNameEvent = mCursor.getString(mCursor.getColumnIndex("name"));
return updateNameEvent;
}
and I´m getting a warning
Warning:(173, 45) Method invocation 'mCursor.getColumnIndex("name")' may produce 'java.lang.NullPointerException'
How i can fix it pls?
mCursor
is null and you make the callmCursor.getColumnIndex("name")
? – Sazerac