I am trying to develop an Android application that will use externally created SQLite database. The required application operational cycle is as follows:
- The database is recreated and populated with data (from another database) on the external (Windows desktop) machine on a regular (daily) basis.
- That database is then pushed into Android device via USB or WIFI.
- The newly pushed database is used to enter new data on the Android device. The entered records are flagged (to distinguish them from the existing ones).
- At the end of the day, the database is pulled from Android device back to the Windows desktop machine (this process needs to be initiated by the Windows application, not by Android application).
- The new (flagged) records are extracted from the SQLite database on the Windows desktop, validated and added to the main Windows desktop database.
- The updated, complete desktop database is then copied into a new SQLite database, which is finally pushed back into the Android device (see point 1 and 2).
Notes:
- List item
- The SQLite database cannot be created on the Android device by the Android application.
- Placing the externally created and populated database in assets directory in the apk is not feasible, as this would only work on the initial application installation, and would not meet the key requirement for a daily database push/pull routine.
- It is not feasible to have the SQLite database stored/imported from the web server, as users would normally not have access to the internet while using this application, i.e. the SQLite database push/pull process needs to be done on Android connected to a standalone Windows machine via USB or WIFI.
- The preference would be to store and access the database from the Android internal storage area (or SDCard), but outside the hidden/protected internal root storage section, i.e. not in /data/data/package_name/databases/, in order to provide users with free access to the database file stored on the Android device.
- The key obstacle appears to be the recognition of the externally created, pushed database by the Android application. I have tested it by copying the database file created by the application into a different folder (still within the data/package_name/.. root section) and then copying it back to the ../databases/ folder. That was sufficient to upset the database access by the application: I would get an "Error opening trace file: no such file or directory (2)", despite trying to open the same unaltered database file. I presume, this restriction is due to the Android 'Sandbox' file security protection ?
How to overcome the above database copy/push/pull issues and how to implement this required database access push/pull model?