无法从 BlackBerry 中的 SQLite 数据库获取值

发布于 2025-01-07 04:02:25 字数 682 浏览 3 评论 0原文

我试图从 SQlite 数据库获取表值,但无法在 DatabaseFactory.open() 处打开 URI。

我写了下面的代码:

    URI myURI = null;
    Cursor cursor = null;
    try 
    {
        myURI = URI.create("/SDCard/databases/itemdb.db");

        try 
        {
            if(DatabaseFactory.exists(myURI))
            {
                Database sqliteDb = DatabaseFactory.open(myURI);
                try 
                {
                    Statement st=sqliteDb.createStatement(query);
                    st.prepare();
                    Logger.out("Grocery", "it is comin here ---- 12");
                    cursor = st.getCursor();
                } 
            }
        }
    }

I am trying to get the table values from the SQlite database, but it is unable to open the URI at DatabaseFactory.open().

I wrote the below code:

    URI myURI = null;
    Cursor cursor = null;
    try 
    {
        myURI = URI.create("/SDCard/databases/itemdb.db");

        try 
        {
            if(DatabaseFactory.exists(myURI))
            {
                Database sqliteDb = DatabaseFactory.open(myURI);
                try 
                {
                    Statement st=sqliteDb.createStatement(query);
                    st.prepare();
                    Logger.out("Grocery", "it is comin here ---- 12");
                    cursor = st.getCursor();
                } 
            }
        }
    }

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

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

发布评论

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

评论(1

流云如水 2025-01-14 04:02:25

如果包含 open() 调用失败时收到的错误消息,那就更好了。

基于此评论:

是的..该 itemdb.db 仅由我的应用程序创建。我已经安装了SD卡。当我将值插入数据库时​​,它会正确发生。我也能看到这些价值观。但只是检索时出现问题..

我猜您已经从插入中打开了数据库。确保插入代码正确关闭数据库,并且已同步,以便读取不会尝试与插入代码同时运行。

It would be better if you included the error message you get when the open() call fails.

Based on this comment:

yes..That itemdb.db is created by my app only. And already i mounted SD card. And when i am inserting the values in the db it is properly happening. I am able to see those values also. But only problem at the time of retrieving..

I am guessing you already have the database open from the insertions. Make sure the insertion code is properly closing the database, and that you have synchronization so that the read does not try to run at the same time as the insertion code.

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