-8
我做了一個無線電應用與listview.the數據存儲在SQLite的db.If我添加新站到App在與「DB瀏覽器SQLite的」新站源碼涉及到最後的地方,因爲它被責令編號100是100位。我希望它由像站與第一place.This名稱的開頭名稱的順序是我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;
}
而且你沒有嘗試過搜索類似「sqlite排序」的東西? –
當然,你沒有正確地搜索。我會給你一個提示,你可以找到你的答案[這裏](https://www.tutorialspoint.com/sqlite/sqlite_order_by.htm) – Kunu
爲什麼不直接使用其他'SQLiteDatabase'方法'查詢(字符串表, \t \t的String []列, \t字符串選擇, \t \t的String [] selectionArgs兩個, \t \t字符串GROUPBY, \t \t字符串有, \t \t字符串排序依據);' – abcOfJavaAndCPP