我创建了一个标签栏,当我第一次进入数据库屏幕时会出现这个标签栏,这段代码工作正常。但是当我们进入另一个选项卡并再次进入数据库屏幕选项卡时,它会引发异常
net.rim.device.api.database.DatabaseIOException: 文件系统错误 (12)
我已经正确关闭了数据库。
我在 finally 块中关闭了数据库。每次移动选项卡时数据库都会关闭
这是我的代码:
    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
        }
    }