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.
- Android sqlite - selecciona registros donde el campo es nulo o vacío
- Almacenamiento de moneda en la base de datos SQlite android
- Android usando SQLCipher - ¿cómo se puede descifrar?
- ¿Es posible simular el cursor sqlite3 en Android cuando no existe db o tabla?
- ¿Por qué no puedo enviar sqlite a Android mediante el comando adb?
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.
- Android table creation Fallo (cerca de "autoincrement": error de sintaxis)?
- ¿Cuál es el modo de subprocesamiento predeterminado de SQLite en Android?
- Configuración de Proguard para enlaces sqlite android
- Compartir base de datos sqlite entre varias actividades de Android
- Android SQLite Eliminar problema de fila
- ¿Es posible mover el DB interno a la tarjeta SD?
- Cursor.getType () y CursorIndexOutOfBoundsException excepción
- Recuperar el valor de incremento automático después de insertar
¡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