Reputation: 1
I have this, but the Student_Name column is not sorting by Ascending order.
row_ID
1
2
3
Student_Name
John
Adam
Bruce
I want to sort this Student_Name to
Adam
Bruce
John
SQLiteDatabse;
SQLiteDatabase getWritableDatabase = this.getWritableDatabase();
public Cursor SortByAscOrder() {
db = getWritableDatabase;
Cursor cursor = db.query(TABLE, null, null, null, null, null, Student_Name + " ASC");
return cursor;
}
MainActivity:
MySQLITE_DATABASE.SortByAscOrder();
I know there are topics similar to this, but I have tried them, but none worke for me. I have spent 2-3 hours searching just for this sorting :-(
Can someone please tell me what I did wrong?
Thank you
Upvotes: 0
Views: 2299
Reputation: 2218
Ascending order is default so you do not need to specify 'asc'
Cursor cursor = db.query(TABLE, null, null, null, null, null, Student_name);
also
your statement db = getWritableDatabase;
did you mean db = getWritableDatabase();
?
Upvotes: 1