[java] getting " (1) no such column: _id10 " error

I'm trying to retrieve the data of a particulate row in a sqlite database . and trying to display it to on a EditText but I'm getting this error , Kindly help me in solving the error !

Thanks in advance :)

here is the logcat data showing error

    12-31 22:28:17.731: E/2.4(12285): 111111 12-31 22:28:17.741: E/2.5(12285): 111111 12-31 22:28:17.771: E/SQLiteLog(12285): (1) no such column: _id10 12-31 22:28:17.791: D/AndroidRuntime(12285): Shutting down VM 

here is the code : ( of the function getName , which is being used to retrieve the data of column 1 ) [getting error after log.e("2.5".... ) ]

 public String getName(long l) {         // TODO Auto-generated method stub         Log.e("2.4","111111");         String[] column = new String[]{KEY_ROWID, KEY_NAME, KEY_HOTNESS };         Log.e("2.5","111111");         Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null);         Log.e("2.6","111111");         if(c != null)         {              Log.e("2.7","111111");             c.moveToFirst();             Log.e("2.8","111111");             String name = c.getString(1);             Log.e("2.9","111111");             return name;          }         return null;     } public String getHotness(long l) {     Log.e("3.1","111111");     // TODO Auto-generated method stub     String[] column = new String[]{KEY_ROWID, KEY_NAME, KEY_HOTNESS };     Log.e("3.2","111111");     Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null);     Log.e("3.3","111111");     if(c != null)      {         Log.e("3.4","111111");         c.moveToFirst();         Log.e("3.5","111111");         String hotness = c.getString(2);         Log.e("3.6","111111");         return hotness;      }     return null; } 

And is the code of the activity which is calling this function

case R.id.bgetInfo:         String s = sqlRow.getText().toString();         long l = Long.parseLong(s);          HotOrNot hon = new HotOrNot(this);         hon.open();         String returnedName = hon.getName(l);         String returnedHotness = hon.getHotness(l);         hon.close();             Log.e("1.2","111111");         sqlName.setText(returnedName);         Log.e("1.3","111111");         sqlHotness.setText(returnedHotness);         Log.e("1.4","111111");         break; 

This question is related to java android sqlite

The answer is


I think you missed a equal sign at:

Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null);  

Change to:

Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + " = " + l, null, null, null, null); 

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to sqlite

getting " (1) no such column: _id10 " error Laravel: PDOException: could not find driver auto create database in Entity Framework Core How to open .SQLite files Accessing an SQLite Database in Swift When does SQLiteOpenHelper onCreate() / onUpgrade() run? Attempt to write a readonly database - Django w/ SELinux error Android sqlite how to check if a record exists How can I add the sqlite3 module to Python? "Insert if not exists" statement in SQLite