当我尝试从我的 sqlite 数据库请求信息时,我收到此错误:
07-19 02:17:10.835: E/AndroidRuntime(689): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.bodprod.dkr/de.bodprod.dkr.MediNotmediList}: java.lang.IllegalArgumentException: You must supply an SQL string
我的数据库请求:
public ArrayList<HashMap<String,Object>> getAllNotmedis(){
ArrayList<HashMap<String,Object>> notmediList = new ArrayList<HashMap<String,Object>>();
String selectQuery = "SELECT medi_id, medi_wirk, medi_handel FROM dkr_medi_liste ORDER BY medi_wirk";
Log.d("ALLNOTMEDIS",selectQuery);
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
HashMap<String , Object> notmedi_item;
if (cursor.moveToFirst()) {
do {
notmedi_item = new HashMap<String, Object>();
notmedi_item.put("sql_id", Integer.parseInt(cursor.getString(0)));
notmedi_item.put("wirk", cursor.getString(1));
notmedi_item.put("handel", unescape(cursor.getString(2)));
notmediList.add(notmedi_item);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return notmediList;
}
这一行产生了错误:
SQLiteDatabase db = this.getWritableDatabase();
为什么我会变成这个错误?数据库存在并充满了数据......