_ID does not exist

Reoneebravece

New Member
I'm trying to obtains data from a slide bbdd and show it in a list view, but I have errors.\[code\]public class DataBaseHelper extends SQLiteOpenHelper{ private static String DB_PATH = "/data/data/com.rbrlnx.lugares/databases/"; private static final String DATABASE_NAME="db.db"; SQLiteDatabase db; String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS lugares (" + " _id INTEGER PRIMARY KEY AUTOINCREMENT, " + "nombre text," + "descripcion text,"+ "latitud real," + "longitud real," + "foto String);"; /*Primero se crea constructor, funcion onCreate, onUpgrade,Abrir y Cerrar*/ public DataBaseHelper(Context context){ super(context,DATABASE_NAME,null,1); } public void onCreate(SQLiteDatabase db){ try { openDataBase(); db.execSQL(CREATE_TABLE); } catch (Exception e) { // handle exception } }public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {} public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DATABASE_NAME; db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE); } public void close(){ db.close(); }/*Despues metodos para a?adir y obtener datos*/ public long addNombre(String nombre){ ContentValues cv = new ContentValues(); cv.put("nombre", nombre);return db.insert("lugares", null, cv); } public long addDescripcion(String descripcion){ ContentValues cv = new ContentValues(); cv.put("descripcion", descripcion); return db.insert("lugares", null, cv); } public long addLatitud(double latitud){ ContentValues cv = new ContentValues(); cv.put("latitud", latitud); return db.insert("lugares", null, cv); } public long addLongitud(double longitud){ ContentValues cv = new ContentValues(); cv.put("longitud", longitud); return db.insert("lugares", null, cv); } public long addFoto(String foto) { ContentValues cv = new ContentValues(); cv.put("foto", foto); return db.insert("lugares", null, cv); } public Cursor getNombres(){ SQLiteDatabase db = this.getWritableDatabase(); Cursor respuesta = db.rawQuery("select nombre from lugares", null); return respuesta; } }\[/code\]and\[code\]public class listatab extends ListActivity{ Context context; ListView listanombres; DataBaseHelper ayudabbdd; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DataBaseHelper ayudabbdd = new DataBaseHelper(this); Cursor nombresC; nombresC = (Cursor) ayudabbdd.getNombres(); startManagingCursor(nombresC); if(nombresC!=null){ ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.listatab, nombresC, new String[] { "nombre" }, new int[] { R.id.lista }); this.setListAdapter(adapter); this.getListView().setTextFilterEnabled(true); } } @Overrideprotected void onDestroy() { super.onDestroy(); if (ayudabbdd != null) { ayudabbdd.close(); } } }\[/code\]And log cat shows me this errors:\[code\]10-11 00:55:49.930: ERROR/AndroidRuntime(32392): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rbrlnx.lugares/com.rbrlnx.lugares.listatab}: java.lang.IllegalArgumentException: column '_id' does not exist10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.widget.TabHost.setCurrentTab(TabHost.java:326)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.view.View.performClick(View.java:2485)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.view.View$PerformClick.run(View.java:9080)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.os.Handler.handleCallback(Handler.java:587)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.os.Handler.dispatchMessage(Handler.java:92)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.os.Looper.loop(Looper.java:130)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at android.app.ActivityThread.main(ActivityThread.java:3683)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at java.lang.reflect.Method.invokeNative(Native Method)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at java.lang.reflect.Method.invoke(Method.java:507)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): at dalvik.system.NativeStart.main(Native Method)10-11 00:55:49.930: ERROR/AndroidRuntime(32392): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist\[/code\]
 
Top