I have a Cordova mobile app and I let the user import a SQLite dababase from an external .db file. I'm using the cordova-sqlite-storage
https://github.com/litehelpers/Cordova-sqlite-storage
A naive solution is already implemented but it's risky. Basically the user selects an external .db file using a file picker which replaces the old .db file
window.plugins.sqlDB.copyDbFromStorage("mydb.db", 0, file, true, onSuccess);
where file is the uri of the new .db file.
It works but I'd like to check the .db file first, at least those two checks:
- check if the .db file is actually a SQLite database
- check if the new SQLite database has some table that must be there before importing
What I've tried
I tried to find a way to open the .db file from its original directory but it seems that the openDatabase() only opens databases stored in the special default location (which is, I guess, the internal private storage for the app)
openDatabase({name: 'test.db', location: 'default'});
other values for the location parameter are simply discouraged, they suggest to stick with default