I wish to sort my listView by the variable called score. Anybody know how to do this? Currently here is my code that get's information from a database and displays it in a list view.
List<String> queryTable(){
List<String> player = new ArrayList<String>();
SQLiteDatabase db = myOpenHelper.getReadableDatabase();
Cursor cursor = db.query(CustomOpenHelper.TABLE_NAME, null, null, null, null, null, null);
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("_id"));
String name = cursor.getString(cursor.getColumnIndex("name"));
int score = cursor.getInt(cursor.getColumnIndex("score"));
player.add(id + " --> the player " + name + " has got a score of " + score +"s");
}
So how would I go about sorting this listview by the variable "score"? Thanks guys.
ORDERY BY columnnameYou can addASCorDESCto get it ascending or descending