I'm working on an app that downloads an SQLite database which is then queried using the
lite4cordova SQLite Plugin. On IOS the plugin reads the databases from the same directory as is returned by FileSystem.root, however on Android it expects the database in the app databases folder, e.g.
file:///data/data/com.example.appname/databases but the FileSystem.root is actually
file:///mnt/sdcard on devices with external storage. The FileTransfer lets me download the database file directly into the databases folder, however I have a function that checks if the database exists before the download using the DirectoryEntry.getFile method. My problem is that I can't seem to use this method on the databases folder since it is outside of the FileSystem root.
The documentation mentions that for both getFile and getDirectory the first parameter can be an absolute path to the file/directory, however unless I'm mistaken I cannot get it to return successful even though I can see the file exists in a file browser.
Example absolute directory:
var dbDirectory = "file:///data/data/" + appIdentifier + "/databases";
this.CheckFileExists = function (fileName, isDb, successCallback, failCallback) {
self.AppFileSystem.root.getDirectory(dbDirectory, {create: false}, function(directory){
directory.getFile(fileName, { create: false }, successCallback, failCallback);
}, failCallback );
};
Example absolute path:
this.CheckFileExists = function (filePath, isDb, successCallback, failCallback) {
self.AppFileSystem.root.getFile(filePath, { create: false }, successCallback, failCallback);
};
Is there any way I can get a DirectoryEntry for the databases folder to check for files?