Created
September 27, 2016 20:27
-
-
Save simoales/99c48a689fd80def883ee86ab20faedd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private long createToDo() { | |
helper = new DatabaseHelper(this); | |
db = helper.getWritableDatabase(); | |
//rawQuery | |
/*String query = "INSERT INTO todos (" | |
+ TodosEntry.COLUMN_TEXT + "," | |
+ TodosEntry.COLUMN_CATEGORY + "," | |
+ TodosEntry.COLUMN_CREATED + "," | |
+ TodosEntry.COLUMN_EXPIRED + "," | |
+ TodosEntry.COLUMN_DONE + ")" | |
+ " VALUES (\"Go to the gym\", 1, \"2016-01-01\", \"\", 0)"; | |
db.execSQL(query);*/ | |
//Insert method; returns the todo ID | |
ContentValues values = new ContentValues(); | |
values.put(TodosEntry.COLUMN_TEXT, "Call Mr Bean"); | |
values.put(TodosEntry.COLUMN_CATEGORY, 1); | |
values.put(TodosEntry.COLUMN_CREATED, "2016-01-02"); | |
values.put(TodosEntry.COLUMN_DONE, 0); | |
// insert row | |
long todo_id = db.insert(TodosEntry.TABLE_NAME, null, values); | |
return todo_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment