No se puede abrir el error de archivo de base de datos al utilizar consultas posteriores

Tengo el código siguiente, el primer objeto del cursor trabaja muy bien, pero cuando hago otra pregunta y la asigno al flightCursor, da el error.

Cursor cursor = database.query( CityAndAirportsTable.notificationsTable, new String[] { CityAndAirportsTable.notifyFlightId }, null, null, null, null, "Id DESC" ); cursor.moveToFirst(); while( !cursor.isAfterLast() ){ String id = String.valueOf( cursor.getInt( 0 ) ); Cursor flightCursor = database.query( CityAndAirportsTable.flightTable, new String[] { CityAndAirportsTable.fromDestinationCode, CityAndAirportsTable.toDestinationCode, CityAndAirportsTable.currentPrice }, CityAndAirportsTable.flightId + "=" + id, null, null, null, null ); } 

Aquí en el flightCursor = database.query, consigo el error.

Registros

 03-27 23:49:09.628: E/SQLiteLog(2296): (14) cannot open file at line 30046 of [9491ba7d73] 03-27 23:49:09.628: E/SQLiteLog(2296): (14) os_unix.c:30046: (24) open(/data/data/com.flightapp.myapp/databases/Application_DB-journal) - 03-27 23:49:09.628: E/SQLiteLog(2296): (14) cannot open file at line 30046 of [9491ba7d73] 03-27 23:49:09.628: E/SQLiteLog(2296): (14) os_unix.c:30046: (24) open(/data/data/com.flightapp.myapp/databases/Application_DB-journal) - 03-27 23:49:09.628: E/SQLiteLog(2296): (14) statement aborts at 11: [SELECT From_Destination_Code, To_Destination_Code, Current_Price FROM Flights WHERE Id=2] unable to open database file 03-27 23:49:09.629: E/SQLiteQuery(2296): exception: unable to open database file (code 14); query: SELECT From_Destination_Code, To_Destination_Code, Current_Price FROM Flights WHERE Id=2 

Hay una pregunta similar sobre stackoverflow, pero en mi caso la primera consulta funciona pero la segunda falla.

¡Cierra el cursor cuando termines con él! Creo que solo tienes demasiados objetos de cursor abiertos

 Cursor cursor = database.query( CityAndAirportsTable.notificationsTable, new String[] { CityAndAirportsTable.notifyFlightId }, null, null, null, null, "Id DESC" ); cursor.moveToFirst(); while( !cursor.isAfterLast() ){ String id = String.valueOf( cursor.getInt( 0 ) ); Cursor flightCursor = database.query( CityAndAirportsTable.flightTable, new String[] { CityAndAirportsTable.fromDestinationCode, CityAndAirportsTable.toDestinationCode, CityAndAirportsTable.currentPrice }, CityAndAirportsTable.flightId + "=" + id, null, null, null, null ); /* Close the cursor here! */ flightCursor.close(); /* ---------------------- */ } 

Esperemos que esto corrija su problema

  • ¿Qué hace exactamente la restricción de clave externa "NO ACTION" de SQLite y cómo es diferente de "RESTRICT"?
  • La base de datos Sqlite debe crearse una sola vez
  • ¿Cuál es el propósito de startManagingCursor?
  • Error de "Error al abrir la base de datos" al copiar una base de datos sqlite de activos En Android 4.2
  • Sqlite3_open_v2 ("/ data / data / com.android.packagename / databases / dump.sqlite", & handle, 1, NULL) falló
  • Creación de una función personalizada en sqlite3 en android
  • Android concurrencia sqlite sin excepciones
  • Rowid en SQLite3 y Android
  • Razones para utilizar la base de datos SQLite legible
  • CompileStatement o db.insert en android
  • Android - Código de error 11 al importar la base de datos Sqlite en Galaxy Note
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.