You having 2 method to insert current date in sqlite database
SQLiteDatabase.execSQL so you can enter a raw SQL query.
-
mDb.execSQL("INSERT INTO "+DATABASE_TABLE+" VALUES (null, datetime()) ");
- Or the java date time capabilities :
// set the format to sql date time SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); ContentValues initialValues = new ContentValues(); initialValues.put("date_created", dateFormat.format(date)); long rowId = mDb.insert(DATABASE_TABLE, null, initialValues);
No comments:
Post a Comment