FileSystem getDirectory or getFile outsite of FileSystem root (Android)

1,998 views
Skip to first unread message

JackRNM

unread,
Oct 25, 2013, 5:59:31 AM10/25/13
to phon...@googlegroups.com
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?

Kerri Shotts

unread,
Oct 25, 2013, 1:40:03 PM10/25/13
to phon...@googlegroups.com
If I understand correctly, the path is absolute to the root of the file system object, not the device's actual file system. The problem is then that there is no way out of the file system jail (no way to get beyond root)

Native code would work for sure- not sure if there is a non-native method that would work here, short of moving your database. 

Sent from my phone. 

___________________________________
Kerri Shotts
photoKandy Studios, LLC


Social Media:
          Twitter: @photokandy, http://twitter.com/photokandy
          Tumblr: http://photokandy.tumblr.com/
          Github: https://github.com/kerrishotts
                        https://github.com/organizations/photokandyStudios
          CoderWall: https://coderwall.com/kerrishotts

Apps on the Apple Store:

Books:
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages