I know this is an old post, but for those who are still here, after searching Google or Bing, this is the solution to this problem:
in createDataBase () the following check exists:
this.getReadableDatabase();
This checks if there is already a database with the specified name and if an empty database is not created so that it can be overwritten using the one in the resource folder. On new devices, this works flawlessly, but there are some devices on which it does not work. Mostly old devices. I donβt know exactly why, but it seems that the getReadableDatabase () function not only gets the database, but also opens it. If you then copy the database from the asset folder on top of it, it still has a pointer to an empty database, and you will get a table that does not contain errors.
So, for it to work on all devices, you must change it to the following lines:
SQLiteDatabase db = this.getReadableDatabase(); if (db.isOpen()){ db.close(); }
Even if the database is open on the check, it closes after that, and this will not give you more problems.
Tom Groentjes Jul 21 '13 at 0:07 2013-07-21 00:07
source share