How to insert a SQLite record with a datetime set to 'now' in Android application?

Posted by droidguy on Stack Overflow See other posts from Stack Overflow or by droidguy
Published on 2009-04-16T03:43:48Z Indexed on 2010/03/21 13:41 UTC
Read the original article Hit count: 243

Filed under:
|

Say, we have a table created as:

  
create table notes (_id integer primary key autoincrement, created_date date)

To insert a record, I'd use

ContentValues initialValues = new ContentValues(); 
initialValues.put("date_created", "");
long rowId = mDb.insert(DATABASE_TABLE, null, initialValues);

But how to set the date_created column to "now"? To make it clear, the

initialValues.put("date_created", "datetime('now')");

Is not the right solution. It just sets the column to "datetime('now')" text.

© Stack Overflow or respective owner

Related posts about android

Related posts about sqlite