与sqlite android的奇怪错误

时间:2014-03-03 21:09:06

标签: android sqlite date

我面临着大而奇怪的问题,我在很多手机上都有sqlite android数据库应用程序是完美的,但是当在lenovo或华硕7英寸平板电脑上使用我的应用程序时,我面临的数据库中没有存储任何记录,所以我认为使用local.getdefualt()

获取当前数据可能存在一些问题

这是我的代码:

INSERT语句:

public long addCheckPoint(String fleetNumber, String NoOFStudents,String Location_Longitude,String Location_Latitude){

        SQLiteDatabase db = this.getWritableDatabase();
String ActionDate =  new SimpleDateFormat("yyyy-MM-ddhh:mm:ss",Locale.getDefault()).format(new Date());

        ContentValues values = new ContentValues(); 
        values.put("FleetNumber", fleetNumber); 
        values.put("CheckPointID", CheckPoint(fleetNumber)); 
        values.put("NoOFStudents", NoOFStudents);
        values.put("Location_Longitude", Location_Longitude);
        values.put("Location_Latitude", Location_Latitude);
        values.put("ActionDate", ActionDate);
        values.put("PathStatus", "Open");

        return  db.insert("CheckPoints",null, values);
    }

获得结果陈述:

    public Cursor getCheckPointRows(String fleetNumber){
    SQLiteDatabase db = this.getWritableDatabase();
    String ActionDate =  new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    String qq = "select CheckPointID , FleetNumber, NoOFStudents , ActionDate from CheckPoints where FleetNumber = "+ fleetNumber +" and date(ActionDate)='"+ActionDate+"'" ;
    Cursor cursor =  db.rawQuery(qq, null);

      if(cursor != null && cursor.moveToFirst()){
          return cursor;
}

     db.close();
    return cursor;

}   

表格strc

          // SQL statement to create CheckPoints table
    String CREATE_CheckPoints_TABLE = "CREATE TABLE CheckPoints ( " +
            "ID INTEGER PRIMARY KEY AUTOINCREMENT , " +
            "FleetNumber INTEGER, "+
            "CheckPointID INTEGER,"+
            "NoOFStudents INTEGER,"+
            "Location_Longitude TEXT,"+
            "Location_Latitude TEXT,"+
            "PathStatus TEXT,"+
            "ActionDate TEXT)" ;

0 个答案:

没有答案