开发者

Problem with sqlite in the android device

I am using sqlite to save some string values in the database, my app works perfectly in t开发者_Go百科he emulator. But when I tried it on the Samsung Galaxy Tab, the log cat says that there are not such tables... before mounting the apk files to the device I have tried opening it in the archive mode and found the database and the tables secure in my "assets" folder. Can any one tell me whats going wrong with me ?

thanks in advance...

Happy coding


Databases don't belong in the assets-folder! You should use a SQLiteOpenHelper-class to create and update your Database when it's needed.

Tutorial (or simply Google for it).


I have experience with the same thing you are experiencing now. This is a classic in device manufacturer fragmentation. It has happened to me before when trying to run an application on a Samsung Nexus S phone that had a method to copy a already existing database to the application from assets on install (i am guessing that's what you are doing at the moment). so long story short, after quite some testing the best and only solution i could find was to actually do the manual work and create the database with the help of the SQLiteHelper methods and table creating queries and recreate the same scheme. this method works 100% so far on every phone i have tried it so that's the safest thing you can do.

Hope this helps.


The db file should be available in "/data/data/YOUR_PACKAGE/databases/" folder in your device.

If this is the first time you are creating the db then you should copy the db file from your assets folder into the above location (the first time when you access the database).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜