我的代码是:
taskDB.insertDate(selectedDate,selectedId);
SQlite DB:
String sql = "CREATE TABLE IF NOT EXISTS " +TABLE_NAME+ "(" +KEY_ID+ " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +KEY_TASKNAME+ " TEXT, " +KEY_STATUS+ " INTEGER," +KEY_FAV+ " INTEGER," +KEY_DATE+ " TEXT"+")";
db.execSQL(sql);
插入查询:
public void insertDate(String date, int id){
String sql = "UPDATE task SET date = "+date+" WHERE id = " +id;
SQLiteDatabase db = this.getWritableDatabase();
Log.d(TAG,"id is:" +id+ ", date is: "+date);// log is below
db.execSQL(sql);
}
日志:
05-26 10:23:14.538 15298-15298/? D/TaskDB: id is:2, date is: 17-05-2017
在插入查询的日志中,我得到了从datepicker
中选择的正确日期,但在表格中它的格式不同。This是插入后sqlite
表的屏幕截图日期