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

Changing the Note Storage model


Now that we've gone through the File API, Promises, and YASMF's FileManager, it's time to update our NoteStorage model to support the new storage mechanism. Almost nothing else needs to change. The look and feel of the app will still function in the same way, but it will use the filesystem for storing notes instead of LocalStorage.

Getting ready

Android versions prior to 4.4 (KitKat) don't natively support easy creation of Blob—what we use to save files to storage. In order to fix this, we need to create a polyfill that will provide this support without having to make changes to the rest of our code.

To do this, create a new file at www/js/lib/Blob.js:

// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// last line modification by Kerri Shotts for PhoneGap Hotshot
try {
  new Blob([]);
} catch (e) {
  var nativeBlob = window.Blob;
  var newBlob...