我正在创建一个示例库应用程序,我正在尝试将库项目存储在本地sqlite数据库中
示例查询:
select filed1 from tablename where filed2="66547";
public List<String> getAllLabels(String number){
List<String> labels = new ArrayList<String>();
String foldername;
// Select All Query
String selectQuery = " SELECT " + Databaseconnect.FILEPATH + " FROM "+ Databaseconnect.TABLE_FILE + " WHERE" + Databaseconnect.FOLDERLINK="+"number;
SQLiteDatabase db = dbHelper.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
labels.add(cursor.getString(0));
} while (cursor.moveToNext());
}
// closing connection
cursor.close();
db.close();
// returning lables
return labels;
}
我仍然有错误,如何在这个查询中写List。。请给我解决方案
试试这个:
String selectQuery =" SELECT " + Databaseconnect.FILEPATH + " FROM "+Databaseconnect.TABLE_FILE + " WHERE " + Databaseconnect.FOLDERLINK + "=" + String.valueOf(number) + ";";