如果當前日期和dealdate之間的差小於15分鐘,我必須運行服務。帶時間戳的ContentResolver查詢
我有創建表DBHelper類:
public class ToDoDBHelper extends SQLiteOpenHelper {
private final int DATABASE_VERSION = 1;
private ArrayList<ToDoClass> todoitems;
private final String DATABASE_NAME = "deals.db";
public ToDoDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
final String Create_Table_Query = "CREATE TABLE "+ ToDoDatabase.ToDoDatabaseEntry.TABLE_NAME+" ("+
ToDoDatabase.ToDoDatabaseEntry._ID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
ToDoDatabase.ToDoDatabaseEntry.start_dealDate_column+" TIMESTAMP ,"+
ToDoDatabase.ToDoDatabaseEntry.end_dealDate_column+" TIMESTAMP ,"+
ToDoDatabase.ToDoDatabaseEntry.shortdescription_column+" TEXT NOT NULL ,"+
ToDoDatabase.ToDoDatabaseEntry.fulldescription_column+" TEXT NOT NULL "+");";
sqLiteDatabase.execSQL(Create_Table_Query);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS "+ToDoDatabase.ToDoDatabaseEntry.TABLE_NAME);
onCreate(sqLiteDatabase);
}
}
和我有ContentResolver的查詢在至極,我想使用的選擇標準:
Cursor cursor = context.getContentResolver().query(
ToDoDatabase.ToDoDatabaseEntry.CONTENT_URI,
null,
selection,
null,
ToDoDatabase.ToDoDatabaseEntry.start_dealDate_column+" DESC");
但我不知道如何編寫選擇。在選擇中,我需要區分ToDoDatabase.ToDoDatabaseEntry.start_dealDate_column和currentDate。
請幫
謝謝你的回答。 –
這對你有用@Renat Ahmetshin? –
也許我必須將日期轉換爲時間戳: String date =「1410293471300」; String [] selectionArgs = new String [] {date}; –