• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem with sqlite query in my app

xscape05

Lurker
hi.

I've got a problem with my application. My query doesn't work correctly, and I don't know what I'm doing wrong. Will anybody be able to help me?

Here is a code I use. Thank you.

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";
}

dictionary.close();
 
SELEC T index_nom_adresse" + word[0].toLowerCase().trim() + " FROM

May have happened in the copy of the text, but there's a space in "SELEC T"

Also, not sure if this bit:

_nom_adresse" + word[0].toLowerCase().trim()

is supposed to be creating a column name or adding a second column to the query. If it's adding a second column, then you're missing a comma.
 
Back
Top Bottom