-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