PhoneGap/Cordova File System Questions
Join the DZone community and get the full member experience.Join For Free
A large majority of the questions I get about PhoneGap and Cordova revolve around the file system API. It has had some pretty significant updates recently but still remains one of the most difficult ones to use. I've been putting off really digging deep into those questions because many times they are incredibly specific to a particular user's application. And - honestly - they typically don't lend themselves to the type of quick questions I can answer during the day.
So with that in mind, I thought it might be fruitful to ask my readers about the API and how I can help make things a bit clearer - for both you and me. What I'm thinking is - can we come up with a list of basic questions, a FAQ perhaps, for just this API. It can't be something too precise to one particular application, but something that can apply to multiple users.
As an example: How do I download an asset to my application? That's a simple question, but it brings up the question of where you would download the asset and how you would actually use it later.
Of course, the big issue is that this particular API is an evolving one. Anything I do today will be outdated next year. But as most of my blog posts on the API are already over a year old, this would at least be a bit fresher. ;)
In order to organize this list, I'm going to start it in the blog entry. Use the comments to make suggestions, and as I see ones that I think make sense, I'll add them to the list. By the way, I know some of these are super trivial, but I figure it doesn't hurt to try to cover as much as possible.
File System FAQ
- When does it make sense to use the file system (versus LocalStorage or WebSQL)?
- How do I download an asset to my application?
- How do I use a file stored in the file system (both binary and text-based files)?
- How do I check to see if a file exists in a directory?
- Are there external tools that can check a device's file system?
- How do I check to see if a directory exists?
- How do I make a subdirectory where the parent directory may not exist?
- Are there any app store restrictions/guidelines for using the file system?
- For iOS, where can I store files so that they will be backed up to iCloud?
- How can I get metadata (size, updated) about a file?
Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.