This object provides a way to obtain root file systems.
LocalFileSystem.PERSISTENT
: Used for storage that should not be removed by the user agent without application or user permission.LocalFileSystem.TEMPORARY
: Used for storage with no guarantee of persistence.The LocalFileSystem
object methods are defined on the window object.
function onSuccess(fileSystem) { console.log(fileSystem.name); } // request the persistent file system window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
function onSuccess(fileEntry) { console.log(fileEntry.name); } window.resolveLocalFileSystemURI("file:///example.txt", onSuccess, onError);
<!DOCTYPE html> <html> <head> <title>Local File System Example</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for PhoneGap to load // document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap is ready // function onDeviceReady() { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); window.resolveLocalFileSystemURI("file:///example.txt", onResolveSuccess, fail); } function onFileSystemSuccess(fileSystem) { console.log(fileSystem.name); } function onResolveSuccess(fileEntry) { console.log(fileEntry.name); } function fail(evt) { console.log(evt.target.error.code); } </script> </head> <body> <h1>Example</h1> <p>Local File System</p> </body> </html>