I made a Radio app with listview.the data is stored on sqlite db.If i add new stations to app over sqlite with "DB Browser for Sqlite" new stations comes to last place because it order it by id.example number 100 is on 100 st place. i want it order by Name like Station beginning with name A on first place.This is my StationDBHandler:
public StationDBHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
setForcedUpgrade();
}
/**
*
* @return list station
*/
public ArrayList<Station> getAllStations() {
ArrayList<Station> stationArrayList = new ArrayList<>();
String selectQuery = "SELECT * FROM " + StationTable.stationTable;
db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
Station station = new Station();
station.setId(cursor.getInt(cursor.getColumnIndex(StationTable.id)));
station.setName(cursor.getString(cursor.getColumnIndex(StationTable.name)));
station.setLogo(cursor.getString(cursor.getColumnIndex(StationTable.logo)));
station.setGenre(cursor.getString(cursor.getColumnIndex(StationTable.genre)));
station.setLongDesc(cursor.getString(cursor.getColumnIndex(StationTable.longDesc)));
station.setStreamUrl(cursor.getString(cursor.getColumnIndex(StationTable.streamUrl)));
stationArrayList.add(station);
} while (cursor.moveToNext());
}
cursor.close();
return stationArrayList;
}