I’ve solved this, thanks all
// Deleting single contact
public void deleteLastMessage(SubliminalMsg a) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME, KEY_MSG + " = ?",
new String[] { String.valueOf(a.get_message()) });
db.close();
}
public String getLastString() {
String selectQuery = "SELECT * FROM " + TABLE_NAME;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
cursor.moveToLast();
LastString = cursor.getString(0);
cursor.close();
db.close();
return LastString;
}
In activity
public void delete(View v) {
LastMessage = new SubliminalMsg(db.getLastString());
db.deleteLastMessage(LastMessage);
displayText();
}
solved SQLite delete last string – app crashed