implement deleting notes

This commit is contained in:
tibbi
2016-10-02 18:25:09 +02:00
parent ee8e8dd17c
commit adac7cbf28
3 changed files with 41 additions and 6 deletions

View File

@ -65,9 +65,9 @@ public class DBHelper extends SQLiteOpenHelper {
db.insert(TABLE_NAME, null, values);
}
public void insertNote(Note note) {
public int insertNote(Note note) {
final ContentValues values = fillContentValues(note);
mDb.insert(TABLE_NAME, null, values);
return (int) mDb.insert(TABLE_NAME, null, values);
}
private ContentValues fillContentValues(Note note) {
@ -77,6 +77,10 @@ public class DBHelper extends SQLiteOpenHelper {
return values;
}
public void deleteNote(int id) {
mDb.delete(TABLE_NAME, COL_ID + " = " + id, null);
}
public boolean doesTitleExist(String title) {
final String cols[] = {COL_ID};
final String selection = COL_TITLE + " = ?";