私はデータベース画面に初めて入力するときに表示されるタブバーを作成しました。このコードは正常に動作しています。私たちは、別のタブに移動して、再び、それは例外データベースを使用しているときに「DatabaseIOException:ファイルシステムエラー(12)」?
net.rim.device.api.database.DatabaseIOExceptionスローデータベース画面のタブに行くときしかし:ファイルシステムエラー(12)
を私が正しく、データベースを閉じています。
I持ってようやくblock.Databaseが、私はこれが私のコードである
]タブに移動していますたびに閉じているが近いデータベース:データベースから選択したタブの上にあなたが値を取得している
Database d = null;
URI _uri = null;
Statement st = null;
Cursor c = null;
try
{
_uri=URI.create("file:///SDCard/MyBudgetTracker.db");
if (DatabaseFactory.exists(_uri)) {
d=DatabaseFactory.openOrCreate(_uri,new DatabaseSecurityOptions(false));
st = d.createStatement("SELECT * FROM "+Globalvalue.planCategoryTable);
st.prepare();
c = st.getCursor();
Row r;
int i = 0;
while(c.next()) {
r = c.getRow();
r.getString(0);
i++;
}
if (i==0)
{
add(new RichTextField("No data in the User table."));
}
}
}catch (Exception e)
{
System.out.println(e.getMessage());
System.out.println(e);
e.printStackTrace();// TODO: handle exception
} finally {
try {
if (DatabaseFactory.exists(_uri)) {
if (c != null) {
c.close();
}if (st != null) {
st.close();
} if (d != null) {
d.close();
}
}
} catch (Exception e2) {
// TODO: handle exception
}
}
Androidですか、いいえ? –
カーソルまたは文を閉じるときに別のエラーが発生する可能性があります。終了コードはすべて同じtry/catchにあるので、データベース自体を閉じることはできません。 –