我的Android應用程序出現問題。我試圖用多個表查詢數據庫並在應用程序中顯示結果。這是一本字典。問題是我的查詢不起作用。我不知道我做錯了什麼。 以下是我使用的代碼示例。如果您需要更多信息,請告訴我。 謝謝。問題與Android應用程序中的我的sqlite查詢
try {
Cursor cursor = dictionary.getDictionaryDatabase().rawQuery("SELECT index_nom_adresse" + word[0].toLowerCase().trim() + " FROM adresse_definition JOIN definition ON adresse_definition.definition = definition.data_id ", null);
//Cursor cursor = dictionary.getDictionaryDatabase().query("adresse_definition", null, "index_nom_adresse= '" + word[0].toLowerCase().trim() + "' or definition= '" + word[0].toUpperCase().trim() + "' ", null, null, null, null);
cursor.moveToFirst();
if (cursor.getCount() != 0) {
if (word[1] == null || word[1].equals("English")) {
translatedWord = cursor.getString(2);
} else {
translatedWord = cursor.getString(1);
}
} else {
translatedWord = "The word is not in database";
}
cursor.close();
} catch (SQLiteException sqle) {
translatedWord = "The word is not in database";
}
這裏是一個logcat的我在嘗試時,搜索詞
03-20 14:34:17.341: I/SqliteDatabaseCpp(516): sqlite returned: error code = 1, msg = no such column: index_nom_adressebonbon, db=/data/data/com.example.application/databases/dict.db
什麼不起作用?你可以例外嗎?你沒有得到任何數據?你得到錯誤的數據? – RvdK 2013-03-20 14:26:38
我沒有收到任何數據,它說'數據庫中沒有這個詞' – user2047427 2013-03-20 14:28:26
是崩潰還是顯示某種錯誤信息? – hardartcore 2013-03-20 14:35:57