sqlite数据库如何插入以及修改date类型的字段
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlite数据库如何插入以及修改date类型的字段相关的知识,希望对你有一定的参考价值。
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类型就可以了。 参考技术A date类型其实就是String类型。
以上是关于sqlite数据库如何插入以及修改date类型的字段的主要内容,如果未能解决你的问题,请参考以下文章