0

我正在尝试将屏幕推送到可能的主 UiApplication (MyApp) 上,具体取决于是否创建了数据库,如果它创建的不是 emapty 或者它是否有一些数据.. 但是当我运行此代码时,我的 balckberry 应用程序 jsts 挂起..

任何帮助表示赞赏:)

我已经检查了虚拟 SDCard 是否存在于模拟器中,我什至有代码可以在运行时检查 SDCard 是否可用。

  • 带有 Eclipse Helios 的 JDE 版本 6.0

  • 插入黑莓模拟器:9800

  • 操作系统:windows 7 32 位终极版

下面是我在我的应用程序中使用的代码

public MyApp()
    {   

        try {
                MyAppURI  = URI.create("file:///SDCard/BlackBerry/Database/"
                        + "MyApp.db");
                this.setMyURI(MyAppURI);

                boolean flag = false;
                flag = DatabaseFactory.exists(getMyURI());
                if ( flag == false){
                    db = DatabaseFactory.create(getMyURI());
                    db.close();
                    new DatabaseSchema(); // this will simpaly create setting table in databse MyApp.db i am closing the database there
                    pushScreen(new Settings());
                }else{
                    db = DatabaseFactory.open(getMyURI());
                    Statement st = db.createStatement("select count(*) from Setting");
                    Cursor cursor = st.getCursor();
                    if (cursor.isEmpty() == true){
                        pushScreen(new Settings());
                    }else{
                        pushScreen(new Reports());
                    }               
                }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
4

1 回答 1

2

理想情况下,您应该在它们自己的线程中运行这些数据库操作,因为它们是阻塞操作。我发现有用的一件事是当我从构造函数中推送它们时,如果它们没有正确显示,则将它们放入调用中pushScreen()invokeLater()这允许系统在显示 a 之前完成任何需要完成的事情,Screen然后它将能够推送。

于 2011-04-21T13:16:13.177 回答