How to insert a SQLite record with a datetime set to 'now' in Android application?
问题 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. 回答1: