I wrote the application for android, all data is selected from the database and displayed on the screen. Tested in genymotion on a Google Galaxy Nexsus 4.2.2 API 17 model, everything was fine. But on all other models, when I tried to run, the data from the database returns false . For example:

Cursor cursor = dbHelper.rawQuery("SELECT * FROM users", null); 

here the cursor returns false , for any query, any column, and so on. But in the model that indicated above, everything works fine. Has anyone come across this?

Ps I tried on emulators with the same version 4.2.2 and API 17, it still does not work.

  • Show all the code to work with the cursor. Plus, what does "here the cursor return false"? Are you cursor.moveToFirst() about cursor.moveToFirst() or what? Well, yes, cursor.close() ? - Suvitruf

1 answer 1

I solved the problem for a long time, but suddenly someone will help.
For the application, it was important to have a pre-prepared database. The problem turned out to be that the database is created when the application is installed, and not stored in the collected apk file. Therefore, when launching an application on any new device, database queries returned false, since it was empty.
The problem was solved by storing the database dump in the project in the assets folder, and when it was first started, the presence of the dump was checked, and the database was copied to the internal directory of the databases (where the database should be). After dump we delete.