我有一个用数据库中的数据填充的微调器。现在,如果微调器为空白并发送数据,则应用程序崩溃并在 NPE 时出错。你建议我做什么?如果微调器为空,请禁用提交按钮?当我禁用提交按钮时?谢谢这是我的微调器的代码,它是 nela Helper 类
public List<String> getAllLabels(){
List<String> labels = new ArrayList<String>();
// Select All Query
String selectQuery = "SELECT * FROM Categorie ";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
labels.add(cursor.getString(1));
} while (cursor.moveToNext());
}
// closing connection
cursor.close();
db.close();
// returning lables
return labels;
}