Android raw query problem
I have a database which has a column of dates in milliseconds. I'm trying to perform a query which allows me to retrieve only the dates that开发者_如何学运维 are greater than the current system time and in ascending order.
This is what I have done, but it doesn't seem to work, help would be most appreciative.
long lowestDate = 0;
long currentTime = System.currentTimeMillis();
String CT = Long.toString(currentTime);
String[] args = {CT};
mDb = mDbHelper.getReadableDatabase();
String mySQL = " select dt"
+ " from reminders"
+ " where dt > " + args[0]
+ " orderby dt Asc ";
Cursor c1 = mDb.rawQuery(mySQL, null);
String mySQL = " select dt"
+ " from reminders"
+ " where dt > " + System.currentTimeMillis()
+ " order by dt Asc ";
"Order by" not "orderby", long to string cast is automatic.
long lowestDate = 0;
long currentTime = System.currentTimeMillis();
String CT = Long.toString(currentTime);
String[] args = {CT};
mDb = mDbHelper.getReadableDatabase();
String mySQL = " select dt"
+ " from reminders"
+ " where dt > '" + args[0]
+ "' orderby dt Asc ";
Cursor c1 = mDb.rawQuery(mySQL, null);
try this
Try
String mySQL = "select dt"
+ " from reminders"
+ " where dt > '" + args[0]
+ "' orderby dt Asc";
精彩评论