データベース画面に初めて入るときに表示されるタブバーを作成しました。このコードは正常に機能しています。しかし、別のタブに移動してから再びデータベース画面のタブに移動すると、例外がスローされます
net.rim.device.api.database.DatabaseIOException: ファイル システム エラー (12)
データベースを適切に閉じました。
最終ブロックでデータベースを閉じました。タブを移動するたびにデータベースが閉じています
これは私のコードです:
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
}
}