2015年11月20日 星期五

Android-Sqlite以遞增or遞減查資料

Cursor的參數
public Cursor query(String table, String[] columns, String selection, 
                 String[] selectionArgs, String groupBy, 
                 String having, String orderBy)


orderBy參數:
遞增:ACS
遞減:DESC

 Cursor cursor = db.query("mCalendar", null, null, null, null, null, null);
if(cursor!=null && cursor.getCount()>0){
  Log.d("##$$##",String.valueOf(cursor.getCount()));
  cursor = db.query("mCalendar", null, null, null, null, null, "_realid DESC");//Change here
  while(cursor.moveToNext()){
    ITEM1=cursor.getInt(1);
    ITEM2=cursor.getInt(2);
         .
         .
         .
    }
}

沒有留言:

張貼留言