SQLiteException:没有这样的表 [英] SQLiteException: no such table

查看:372
本文介绍了SQLiteException:没有这样的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我自己的sqlite3的数据库,而不是创建一个新的,每次我的应用程序运行,因为我有静态数据几张桌子,我想显示。我建立了我的数据库,并把它放在我的资产文件夹中。然后,我创建了我的数据库帮助,当我开始我的应用程序,我可以毫无问题地打开我的数据库,但是当我尝试使用下面的code打开我的第一个表

I am using my own SQLite3 database as opposed to creating a new one each time my app runs, as I have a few tables with static data that I am trying to display. I created my database and placed it in my assets folder. I then created my database helper and when I start my app I can open my database without problem but when I try to open my first table using the following code

private Cursor getData() 
{
    try
    {
        myDbHelper = new DatabaseHelper(this);
        SQLiteDatabase db = myDbHelper.getReadableDatabase();
        Cursor cursor = db.query("exhibitor", FROM, null, null, null,null, ORDER_BY);
        startManagingCursor(cursor);
        return cursor;
    }
    catch(SQLiteException e)
    {
        String err = e.toString();
        return null;
    }
}


它抛出一个错误说 android.database.sqlite.SQLiteException:没有这样的表:参展商:在编制:选择_id,参展单位从参展商ORDER BY展商但是当我检查数据库参展商是存在的。

我缺少什么?


It throws an error saying android.database.sqlite.SQLiteException: no such table: exhibitor: , while compiling: SELECT _id, EXHIBITOR FROM exhibitor ORDER BY EXHIBITOR but when I check the database exhibitor is there.

What am I missing?

推荐答案

你有没有移动的资产文件夹中的数据库 /数据/数据​​/ YOUR_PACKAGE /数据库/ 上模拟器?

Have you moved the database from the assets folder to /data/data/YOUR_PACKAGE/databases/ on the emulator?

这是一个好详细的帖子有关数据库移动到 /数据/数据​​/ YOUR_PACKAGE /数据库/ ,如果它不存在。

This is a good detailed post about moving the database to /data/data/YOUR_PACKAGE/databases/ if it does not exist.

<一个href="http://stackoverflow.com/questions/3013021/embed-a-database-in-the-apk-of-a-distributed-application-android">Here另一种是短期和简单的解决方案吧。

Here is another short and simple solution to it.

这篇关于SQLiteException:没有这样的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆