sqlite数据库中插入date类型用string类型,如下:
public void insert(String dailyGuid, String dailyCreateDate, String dailyUpdateDate, String dailyContactGuid,
String dailyEmployeeGuid, String dailyContent, String dailyType, String dailyTypeValue,
String dailyEstimateRate, String dailyRealRate, String dailyMemo, String dailyApproval,
String dailyExecuteDate, String dailyRemindSign, String dailyTime, String dailyIsdel){
SQLiteDatabase db=this.getWritableDatabase();
db.execSQL("INSERT INTO TBL_DAILY(dailyGuid, dailyCreateDate, dailyUpdateDate, dailyContactGuid, " +
"dailyEmployeeGuid, dailyContent, dailyType, dailyTypeValue, " +
"dailyEstimateRate, dailyRealRate, dailyMemo, dailyApproval, " +
"dailyExecuteDate, dailyRemindSign, dailyTime, dailyIsdel) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
new String[]{dailyGuid, dailyCreateDate, dailyUpdateDate, dailyContactGuid,
dailyEmployeeGuid, dailyContent, dailyType, dailyTypeValue,
dailyEstimateRate, dailyRealRate, dailyMemo, dailyApproval,
dailyExecuteDate, dailyRemindSign, dailyTime, dailyIsdel});
}
更新动作如下:
public void update(String dailyGuid, String dailyCreateDate, String dailyUpdateDate, String dailyContactGuid,
String dailyEmployeeGuid, String dailyContent, String dailyType, String dailyTypeValue,
String dailyEstimateRate, String dailyRealRate, String dailyMemo, String dailyApproval,
String dailyExecuteDate, String dailyRemindSign, String dailyTime, String dailyIsdel){
SQLiteDatabase db=this.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put("dailyGuid", dailyGuid);
cv.put("dailyCreateDate", dailyCreateDate);
cv.put("dailyUpdateDate", dailyUpdateDate);
cv.put("dailyContactGuid", dailyContactGuid);
cv.put("dailyEmployeeGuid", dailyEmployeeGuid);
cv.put("dailyContent", dailyContent);
cv.put("dailyType", dailyType);
cv.put("dailyTypeValue", dailyTypeValue);
cv.put("dailyEstimateRate", dailyEstimateRate);
cv.put("dailyRealRate", dailyRealRate);
cv.put("dailyMemo", dailyMemo);
cv.put("dailyApproval", dailyApproval);
cv.put("dailyExecuteDate", dailyExecuteDate);
cv.put("dailyRemindSign", dailyRemindSign);
cv.put("dailyTime", dailyTime);
cv.put("dailyIsdel", dailyIsdel);
db.update("TBL_DAILY", cv, "dailyGuid=?", new String[]{dailyGuid});
}
public void delete(String dailyGuid){
SQLiteDatabase db=this.getWritableDatabase();
db.delete("TBL_DAILY", "dailyGuid=?", new String[]{dailyGuid});
}
注意:sqlite其中的数据 类型是可以很容易的进行转换的,提取的时候如果需要可以将String在转为date类型就可以了。
date类型其实就是String类型。