S
spike
Neues Mitglied
Hi Leute,
ich habe ein Problem, das ich bisher leider noch nicht lösen konnte.
Ich öffne in meiner Activit eine Datenbank-Verbindung.
Das mache mit Hilfe eines DB Helfers
In meiner onPause und onDestroy Methode schließe ich die DB wieder:
mHelper.close();
Wenn ich nun in meiner Activity eine Kontextmenü aufrufe und dort irgendwas auswähle, bekomme ich immer diesen Fehler:
close() was never explicitly called on database '/mnt/sdcard/de.androiddev.mytestapp/test.db'
Ich schließe doch aber die DB oder etwa nicht?
Mittels Google Suche konnte ich leider keine Lösung dafür finden. Dort steht überall das man in onPause und onDestroy die DB schließen soll und das mach ich ja....
Gruß
Spike
ich habe ein Problem, das ich bisher leider noch nicht lösen konnte.
Ich öffne in meiner Activit eine Datenbank-Verbindung.
Das mache mit Hilfe eines DB Helfers
Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]private[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] openDataBase(){
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]myDataBase[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mCursor[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mHelper[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DatenbankManager([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mHelper[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].createDataBase();
} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (IOException ioe) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]throw[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Error([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Unable to create database"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mHelper[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].openDataBase();
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]myDataBase[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mHelper[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getDatabase();
} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](SQLException sqle){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]throw[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sqle;
}[/LEFT]
}
[/SIZE]
mHelper.close();
Wenn ich nun in meiner Activity eine Kontextmenü aufrufe und dort irgendwas auswähle, bekomme ich immer diesen Fehler:
close() was never explicitly called on database '/mnt/sdcard/de.androiddev.mytestapp/test.db'
Ich schließe doch aber die DB oder etwa nicht?
Mittels Google Suche konnte ich leider keine Lösung dafür finden. Dort steht überall das man in onPause und onDestroy die DB schließen soll und das mach ich ja....
Gruß
Spike