SQLite Exception: no such table Error [duplicate]

不问归期 提交于 2020-02-10 03:27:05

问题


Possible Duplicate:
Android Sqlite - “No Such Table” Error

We are trying to develop an application on Android. We are using SQLite database and on phone we are getting

SQLiteException:no such table.

It is working fine on simulator.

Can anyone provide any input on this?


回答1:


If you don't specify the database file name correctly I believe it falls back to creating an empty database. This is generally the cause of 'table not found'. Check your path and database file name.




回答2:


I had faced a different flavour of the same problem.

I was getting no such table error when I try to insert.

Before inserting, the code was calling

mDb = mDbHelper.getWritableDatabase(); 

getWritableDatabase() , when called first time will call onCreate()

I had my SQL query to create the table within this oncreate method

public void onCreate(SQLiteDatabase db) {

            db.execSQL(DATABASE_CREATE);
            Log.v("INFO1","creating db");
            //Toast.makeText(mCtx, "created", Toast.LENGTH_SHORT).show();
        }

So for me what had happened was, the db was successfully created when the application was first run but no table due to some other errors. Later whenever the application is run, onCreate() is never called as db is already there and thus no table created, so all further SQL commands failed.

So I moved creating table out of onCreate() , and now its working




回答3:


Some people have been able to solve the problem using the steps mentioned here. It seems to me that this problem exists on certain versions of Android 2.2. I have incorporated this change in my code, though I'm still looking for Beta testers with to see if it actually works.



来源:https://stackoverflow.com/questions/934237/sqlite-exception-no-such-table-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!