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 from that phone and it is having all the tables that are required. I know it is a bit weird but this error is only coming on OnePlusTwo device. So my question is this a device specific issue or general issue faced by anyone else. Please do mention if anyone is facing this issue on any other phone or know how to resolve this issue. I haven't posted any code because it is coming on only one device, but if anyone needs please mention I will post that part
Asked
Active
Viewed 1,179 times
4
-
I am facing the same issue. – Vipul Asri Oct 07 '15 at 08:47
-
1While I don't know the answer to your question I just want to add on to this: there are several other weird issues that happen with OnePlus only, such as not being able to control what the 'Enter' button on the keyboard does in an EditText. – nbokmans Oct 07 '15 at 08:57
-
That is what I want to confirm that is this any kind of device specific issue or I have to do something special for this issue. Anyways thanks :) – varun bhardwaj Oct 07 '15 at 09:02
1 Answers
7
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 :)

varun bhardwaj
- 1,522
- 13
- 24
-
can you please elaborate little bit more with some more code as am also getting same error, please – Oct 20 '15 at 10:28
-
Have tested this fix on other devices as well; and result is, that it runs as usual on all other devices and now it does not even trouble on OnePlus. – Darpan Oct 26 '15 at 12:28
-
1@RahulSharma you just have to close the database access you have taken before copying the assets db to your app db. The process is first the db is created when app is launched for the first time and just after that you copy the database. You just have to get a readable access to your db before starting the copy process and close that db instance. – varun bhardwaj Oct 28 '15 at 07:14