Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By : Kerri Shotts
Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By: Kerri Shotts

Overview of this book

<p>PhoneGap allows you to use your existing knowledge of HTML, CSS, and JavaScript to create useful and exciting mobile applications.<br /><br />This book will present you with 12 exciting projects that will introduce you to the dynamic world of app development in PhoneGap. Starting with their design and following through to their completion, you will develop real-world mobile applications. Each app uses a combination of core PhoneGap technologies, plugins, and various frameworks covering the necessary concepts you can use to create many more great apps for mobile devices.</p>
Table of Contents (21 chapters)
PhoneGap 3.x Mobile Application Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. The File API

One critical feature of applications is that they usually need to store the user's data persistently. Until now, we've been using localStorage for our application, but it would be even better if we could use the device's actual filesystem.

This is where the File API comes in. It's actually not specific to Cordova; there are several browsers that support the File API (to varying degrees). The specification itself is defined by the W3C (http://www.w3.org/TR/FileAPI/ and http://www.w3.org/TR/file-system-api/).

The File API gives you the ability to access your app's sandboxed filesystem. That means you can create folders and files, move them around, copy them, edit them, and delete them, just like you can with native code.

There's only one downside: the API itself is largely asynchronous, which usually means venturing into "callback hell"; not a very fun place to be. It can be incredibly difficult to debug a callback chain or prevent such a chain from devolving into spaghetti...