How to use my own sqlite database?

后端 未结 7 512
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 15:20

I put my database field in \"assets\" folder. And use the code from this blog to copy the database to \"/data/data/my_packname/databases/\", (This copy code i run it in the

7条回答
  •  再見小時候
    2020-12-02 15:22

    I know this is an old question, but I lost a lot of time figuring it out, with the help of all the replies.


    The issue is that a device stores a database in his data/data/.../databases folder. So, when you change sth about the database (name, add android metadata table, size..) it wont make any difference because of the stored database and the method that checked for existing database.


    To get the newest database, after changing it, you must run the program without checking for existing databses (e.g. instead of dbExist = checkDataBase(); make it just false).

    dbExist = checkDataBase();
    

    Change to:

    dbExists = false;
    

    After you picked up the "new" databse you can return to checking the existing ones.

    Hope it helps someone, dina

提交回复
热议问题