Sqlite return no such table but table is present when fetched on OnePlusTwo device

后端 未结 1 1048
暗喜
暗喜 2021-01-13 21:29

I had copied a db file from assets to the app database and it is successfully copied. When I query on any table it returns no such table exception. I fetched the db file fro

1条回答
  •  孤城傲影
    2021-01-13 22:15

    I solved this problem by putting a single line of code before copying the database. The problem is when you created the database you need to close it first before opening any stream on it. This issue was not with many of the devices as now all devices handle these situations but some devices like OnePlusTwo are giving error on this. So following is the line you need to add just before copying the database:

    getReadableDatabase().close();
    

    This will close the connection first and then open a output stream on the created database. If anyone need some extra code, I can post a sample code. If this doesn't fix the issue please post your database copy code.

    Thanks :)

    0 讨论(0)
提交回复
热议问题