开发者

android.database.sqlite.SQLiteException: no such table: TableName [duplicate]

This question already has answers here: problem about sqlite database, no such table: (4 answers) Closed 5 years ago.

I have a database [sqllite] in my assets folder and it have all the tables and fields which I have given in my query. But still while executing the app it shows some sqlite error like

开发者_开发百科
09-30 13:09:53.656: ERROR/AndroidRuntime(334): Caused by: android.database.sqlite.SQLiteException: no such table: Table_name Query

Happy Coding..!


I solved the "no such table" exception by simple tricks. So first in the method createDatabse(), replace the "Error copying databse" with e.toString() so that you can see the real problem you are up against. Lets begin: first, the emulator will not check your database for any changes hence the many instances of same error no matter what you do. You need to trick it that the database it had stored nolonger exists then let it raise an error. If none of that works, try my dirty trick. You will need do clear the app settings on the emulator Settings->Apps->YOUR_APP->Clear Data. But don't stop there. You will then delete the database from the assets folder, right click app folder->Refresh, and copy into the folder the new database. Right click on the assets->Build Path->Use as Source Folder. I used a trick to inform the ide that I had no db, by commenting out this.getReadableDatabase(); then running the app so that it raises an error, then I un-commented and it worked well. I have done this twice now

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜