1
我已將一個數據庫合併到我的黑莓應用程序中。當我啓動應用程序時,數據庫會建立,並將值插入到數據庫中。然而,當我改變類,即使用這種在Blackberry中切換課程時數據丟失
HelloBlackBerryScreen bbScreen = new HelloBlackBerryScreen();
UiApplication.getUiApplication().pushScreen(bbScreen);
this.invalidate();
當我重裝之前的類我得到這個:
[0.0] FileIO:fileinfo start 5e2
[0.0] FileIO:info by name complete 5e2
[0.0] FileIO:fileinfo start 5e3
[0.0] FileIO:info by name complete 5e3
[0.0] FileIO:open start 5e4
[0.0] FileIO:open complete 5e4
[0.0] FileSystem:bad open status 12
[0.0] File system error (12)read error here
[0.0] No stack trace
當應用程序initally啓動時,它讀取數據庫的罰款,並一定值就會被裝在相關領域,然後我切換到另一個類,它也可以訪問數據庫,然後切換回第一個類,我得到了這個錯誤。當我進入下一堂課時,我沒有正確地關閉數據庫嗎?
下面是我用得到數據庫值碼:
public void getValues(){
try {
URI uri = URI.create("file:///SDCard/Databases/" + "database2.db");
sqliteDB = DatabaseFactory.open(uri);
Statement st = sqliteDB.createStatement("SELECT Signauto,SaveP FROM options");
st.prepare();
Cursor c = st.getCursor();
Row r;
int i = 0;
while(c.next())
{
r = c.getRow();
i++;
System.out.println(r.getString(0) + "HERE");
System.out.println(r.getString(1) + "HERE");
if(r.getString(0).equals("true")){
tickBoxes[1] = true;
//signAuto();
}
else{
tickBoxes[1] = false;
}
if(r.getString(1).equals("true")){
tickBoxes[0] = true;
setUserPass();
}
else{
tickBoxes[0] = false;
}
}
if (i==0)
{
System.out.println("No data in the options table.");
}
st.close();
sqliteDB.close();
}
catch (Exception e) {
System.out.println(e.getMessage() + "read error here");
e.printStackTrace();
}
}
我來試試看 –