user1203673
user1203673

Reputation: 1015

how to query to get the last inserted data as first item in the list android

Iam retrieving data from the database and displaying it as a list, in the list i want to display the last inserted one as the first and soon How to acheive this?

Iam fetching data using the following query

public Cursor fetchdata() {
        DBHelper.onOpen(db);
        Cursor mCursor = db.query(DATABASE_Table, new String[] { "Message",
                , "UserInfo",  "timeStamp" }, null,
                null, null, null, null);

        return mCursor;
    }

Upvotes: 0

Views: 1154

Answers (2)

Khan
Khan

Reputation: 7605

i think you have use this way may help full

 Cursor c=dbAdapter.fetchdata();
 int MSG=.getColumnIndex("Message");
 for(c.moveToLast();!c.isBeforeFirst();c.moveToPrevious())
           {

    }

Upvotes: 0

Chandra Sekhar
Chandra Sekhar

Reputation: 19500

use the method of Cursor class mCursor.moveToLast();

Upvotes: 2

Related Questions