基于 sqlite 数据库中的数据在 Blackberry UI 应用程序上推送屏幕时出现问题

发布于 2024-11-02 19:18:24 字数 1551 浏览 7 评论 0原文

我试图根据数据库是否创建以及是否创建来将屏幕推到主 UiApplication (MyApp) 上,如果创建了,那么它是 emapty 还是有一些数据。 但是当我运行此代码时,我的 balckberry 应用程序 jsts 挂起..

感谢任何帮助:)

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

  • JDE 版本 6.0,带 Eclipse Helios

  • 插入 BlackBerry Simulator:9800

  • 操作系统:windows 7 32 位终极版< /p>

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

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();
        }

    }

I am trying to push the screen on may main UiApplication (MyApp) based on the either database is created or not and if its created than is it emapty or is it having some data..
but when i run this code my balckberry application jsts hangs ..

any help is appreciated :)

i have checked that the virtual SDCard is there in simulator and i have even code to check at runtime whether SDCard is avialable or not.

  • JDE Version 6.0 with Eclipse Helios

  • plug in BlackBerry Simulator : 9800

  • Os : windows 7 32 bit ultimate edition

below is my code that i am using in my app

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();
        }

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒浓于脸红 2024-11-09 19:18:24

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

Ideally you should be running these database operations in their own Thread, as they are blocking operations. One thing that I've found helpful is to put my pushScreen()s in invokeLater() calls when I'm pushing them from a constructor if they aren't displaying properly. This allows the system to finish anything that needs to be done prior to displaying a Screen, and then it will be able to push.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文