Skip to content

Instantly share code, notes, and snippets.

@nathancyam
Created June 9, 2013 14:22
Show Gist options
  • Save nathancyam/5743730 to your computer and use it in GitHub Desktop.
Save nathancyam/5743730 to your computer and use it in GitHub Desktop.
GODDAMN SQLITE
public Event createEvent(String location, String dateString, String timeString, String nameString){
ContentValues values = new ContentValues();
values.put(MySQLiteHelper.COLUMN_LOCATION, location);
values.put(MySQLiteHelper.COLUMN_DATE, dateString);
values.put(MySQLiteHelper.COLUMN_TIME, timeString);
values.put(MySQLiteHelper.COLUMN_NAME, nameString);
// This inserts the entry to the database
long insertId = database.insert(MySQLiteHelper.TABLE_EVENTS, null, values);
// This makes sure that the database points to the new product
Cursor cursor = database.query(MySQLiteHelper.TABLE_EVENTS,
allColumns, MySQLiteHelper.COLUMN_ID + " = " + insertId, null,
null, null, null);
cursor.moveToFirst();
Event newEvent = cursorToEvent(cursor);
cursor.close();
return newEvent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment