【发布时间】:2015-09-28 04:51:45
【问题描述】:
我正在保存数据的提交日期,但我插入的日期更改为当前日期
当你保存数据时
Calendar currentDate=Calendar.getInstance();
DatabaseOperations DB = new DatabaseOperations(ctx);
DB.putInformation(DB, done_today1 + "\n" + done_today2 + "\n" + done_today3, thankful_for1 + "\n" + thankful_for2 + "\n" + thankful_for3 + "\n" + thankful_for4 + "\n" + thankful_for5, for_relationship, for_kids, for_business, currentDate.get(Calendar.DATE) + "-" + currentDate.get(Calendar.MONTH) + "-" + currentDate.get(Calendar.YEAR));
将数据插入表中
public void putInformation(DatabaseOperations dop,String happenedToday,String thankfulFor,String forRelationship,String forKids,String forBusiness,String currentDate){
SQLiteDatabase SQ=dop.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put(TableData.TableInfo.DONE_TODAY, happenedToday);
cv.put(TableData.TableInfo.THANKFUL_FOR,thankfulFor);
cv.put(TableData.TableInfo.FOR_RELATIONSHIP,forRelationship);
cv.put(TableData.TableInfo.FOR_KIDS,forKids);
cv.put(TableData.TableInfo.FOR_BUSINESS,forBusiness);
cv.put(TableData.TableInfo.CURRENT_DATE,currentDate);
SQ.insert(TableData.TableInfo.TABLE_NAME, null, cv);
Log.d("Database operations", "One Row Inserted");
当我以这种方式检索日期时
Cursor CR = dop.getInformation(dop);
CR.moveToFirst();
Toast.makeText(DisplayTable.this,""+CR.getString(5),Toast.LENGTH_LONG).show();
我得到的是当前日期,而不是提交数据的日期。
有人知道为什么会这样吗?
【问题讨论】: