获取sqlLite中最后一行和列的值

时间:2016-08-21 04:29:42

标签: java android sql sqlite

我想得到最后一个值示例

ID NAME SURNAME
1  Mark X
2  Alex Z

我想获得surname等于Z的值,或者插入的最后一个值y具有此代码

DB CLASS

 public Cursor getData(){

    SQLiteDatabase db = this.getWritableDatabase();
    //String selectQuery= "SELECT * FROM "+TABLE_NAME+" ORDER BY column DESC LIMIT 1;";
    Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_NAME,null);

   //Cursor cursor = db.rawQuery(selectQuery,null);




    return cursor;



}

主要活动

 void getDatas(){
   Cursor c =  helper.getData();
    if (c.getCount()==0){

        return;

    }

    StringBuffer buffer = new StringBuffer();
    while (c.moveToNext()){
            buffer.append(c.getString(2));

    }

    TEXT=buffer.toString();

}

我得到的例子是= XZ而不是Z

1 个答案:

答案 0 :(得分:1)

我想你想要这样的东西:

filtered = filter(check_time, os.listdir(r'my/path'))