Monday, 15 July 2013

android - getting error "Can't read row# 0, col# 2 from CursorWindow. Make sure your Cursor is initialized correctly." -


I am developing an Android app. I am trying to display a user input, however when I do this If I try, I get the error message above. I do not know what I'm doing wrong here is a code that I use. Thank you.

  try {cursor cursor = glossary.getgeardatabase (). RawQuery ("select catgram fROM adresse_definition WHERE definition = '" + word [0] .toLowerCase (.) Trim () + "'", zero); // cursor cursor = glossary Database () RawQuery ("Select index_name_addresses" + word [0] .toolware () .trim () + Add definition from adresse_definition to adresse_definition.definition = "on definition.data_id", zero); // cursor cursor = glossary Database () Query ("adresse_definition", null, "index_nom_adresse = '" word [0] .toLowerCase (). Trim () + "' or definition = '" word [0] .tocharcas (.) Trim () + "'", Empty, null, empty, blank); Cursor.moveToFirst (); If (cursor .getcount ()! = 0) {if (word [1] == null || word [1] .equals ("english")) {translatedWord = cursor.getString (2); } And (translated word = cursor.gate string (1);}} Else {translatedWord = "word is not in database"}} Cursor.close ();} hold (SQLiteException sqle) {translatedWord = "word is not in database ";} Dictionary.close ();    

Check if you have all the words in your query Selecting the column that you are going to get from the cursor. Now you are just selecting one column and you can get two columns in the cursor .getString. Change the query to:

  Select * from table_name where ...    

No comments:

Post a Comment