SlideShare a Scribd company logo
1 of 80
Download to read offline
Gran Sasso Science Institute
Ivano Malavolta
Local Storage
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
Local storage and ļ¬le system access
There are 4 ways to store data locally in Cordova:
ā€¢ā€Æ Web storage
ā€¢ā€Æ Local Storage
ā€¢ā€Æ Session Storage
ā€¢ā€Æ WebSQL
ā€¢ā€Æ Indexed DB
ā€¢ā€Æ File System Access
Web storage, WebSQL, and
IndexedDB conform to W3C
speciļ¬cations and are provided
by the browser itself
File system access API conforms to its
corresponding W3C speciļ¬cation
Web Storage
LocalStorage
stores data in key/value pairs
persists across browser sessions
SessionStorage
stores data in key/value pairs
data is erased when a browser session ends
WebSQL
relational DB
support for tables creation, insert, update, ā€¦
transactional
persists across browser sessions
WebSQL
It provides you a structured SQL relational database
You have to setup a DB schema
You can then perform classical SQL queries
tx.executeSql(ā€˜SELECT	
 Ā *	
 Ā FROM	
 Ā Userā€™,	
 Ā [],	
 Ā 
	
 Ā 	
 Ā  	
 Ā function(tx,	
 Ā result)	
 Ā {	
 Ā 
	
 Ā 	
 Ā  	
 Ā  	
 Ā //	
 Ā callback	
 Ā code	
 Ā 
});	
 Ā 
IndexedDB
ā€¢ā€Æ It combines Web Storage and WebSQL
ā€¢ā€Æ You can save data as key/value pairs
ā€¢ā€Æ You can deļ¬ne multiple DBs
ā€¢ā€Æ Good Performance
ā€“ā€Æ data is indexed
ā€“ā€Æ Asynchronous Ć ļƒ  it does not block the UI
You can see a store as a big SQL table with only key/value pairs
Ć ļƒ  you donā€™t need to deļ¬ne a schema upfront
File System
ā€¢ā€Æ you can access ļ¬les locally to your app
ā€¢ā€Æ supports main FS operation
ā€“ā€Æ creation, move, delete, rename, etc.
ā€¢ā€Æ it is not transactional
ā€¢ā€Æ persists across browser sessions
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
Web Storage
It is based on a single persistent object called
localStorage
You can set values by calling
window.localStorage.setItem(ā€œnameā€, ā€œIvanoā€);
You can get values back by calling
var name = window.localStorage.getItem(ā€œnameā€);
Supported Methods
.key(0)
Returns the name of the key at the position speciļ¬ed
.getItem(ā€œkeyā€)
Returns the item identiļ¬ed by it's key
.setItem(ā€œkeyā€, ā€œvalueā€)
Saves and item at the key provided
.removeItem(ā€œkeyā€)
Removes the item identiļ¬ed by it's key
.clear()
Removes all the key-value pairs
Complex Objects
Current implementations support only string-to-string mappings
Ć ļƒ ā€Æ you can store only strings
Ć ļƒ ā€Æ keys can be only strings
You can use JSON serialization if you need to store complex data
structures
Example of JSON Serialization
// simple class declaration
function Person(name, surname) {
this.name = name;
this.surname = surname;
}
// object creation
var user = new Person(ā€˜Ivanoā€™, ā€˜Malavoltaā€™);
// object serialization
window.localStorage.setItem(ā€œuserā€, JSON.stringify(user));
// object retrieval
var current =
JSON.parse(window.localStorage.getItem(ā€œuserā€));
Checking Existence
You can simply check if the needed element is == null
if (window.localStorage.getItem(ā€œuserā€)) {
// there is an object in user
} else {
// the user key does not have any value
}
Selecting elements
In this case you have to manually iterate on elements
var users = [...]; // array of Person objects
window.localStorage.setItem(ā€œusersā€,
JSON.stringify(users));
var allUsers =
JSON.parse(window.localStorage.getItem(ā€œusersā€));
var ivanos = [];
for(var i=0; i<allUsers.length; i++) {
if(allUsers[i].name == ā€˜Ivanoā€™)
ivanos.push(allUsers[i]);
}
Counting Elements
Also in this case, we have to do it manually
var usersNumber =
JSON.parse(window.localStorage.getItem(ā€œusersā€œ)).length;
Session Storage
Session Storage provides the same interface as Local Storage
Ć ļƒ  you can call the same methods
but
Session Storage is cleared between app launches
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
WebSQL
It provides you a structured SQL relational database
You have to setup a DB schema
You can then perform classical SQL queries
tx.executeSql("SELECT * FROM Userā€œ, [],
function(tx, result) {
// callback code
});
Opening a DB
Done via a dedicated function
var db =
openDatabase(ā€˜Test', ā€˜1.0', ā€˜Test DB', 100000);
It creates a new SQLite DB and returns a new Database object
The Database object will be used to manipulate the data
Opening a DB: syntax
openDatabase(name, version, displayname, size);
name
the name of the DB
version
the version of the DB
displayname
the display name of the DB
size
the size of the DB in bytes
Database
It allows to manipulate the data via 2 methods:
changeVersion
atomically verify the version number and change it
db.changeVersion("1.0", "1.1");
transaction
performs a DB transaction
Transactions
It allow you to execute SQL statements against theĀ DB
db.transaction(queries, error, success);
3 functions as parameters:
queries : contains the queries to be performed
error : executed if the transaction results in an error
success : executed if the transaction terminates correctly
Transaction Example
http://bit.ly/JlUJde
executeSql
It is the method that performs a SQL statement
The user can build up a database transaction by calling the
executeSql method multiple times
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS USER');
tx.executeSql('CREATE TABLE IF NOT EXISTS USER (id
unique, name, surname)');
tx.executeSql('INSERT INTO USER(id, name, surname)
VALUES (1, ?, ?)ā€˜, [ā€œIvanoā€œ, ā€œMalavoltaā€œ],
success, error);
}
Result Sets
When the executeSql method is called, it will invoke it's callback
with a SQLResultSet parameter
It has 3 properties:
insertId
the ID of the row that has been inserted
rowsAffected
the number of rows changed by the SQL statement
rows
the data returned from a SQL select statement
rows is an object of type SQLResultSetListĀ 
Results Sets Example
...
tx.executeSql('INSERT INTO USER(id, name,surname) VALUES
(5, ?, ?)ā€˜, [ā€œIvanoā€œ, ā€œMalavoltaā€œ], success, error);
}
function success(tx, results) {
var affected = results.rowsAffected(); // 1
}
function error(err) {
// code for managing the error
}
Result Set Lists
It contains the data returned from a SQL Select statement
length
the number of rows returned by the SQL query
Ā 
item(index)
returns the row at the speciļ¬ed index represented by a JavaScript
object
Result Set List Example
...
tx.executeSql(ā€˜SELECT * FROM USERā€˜, [], success, error);
}
function success(tx, results) {
var size = results.rows.length;
for (var i=0; i<size; i++){
console.log(results.rows.item(i).name);
}
}
Errors
It contains information about an occurred error
code
A predeļ¬ned error code
es. UNKNOWN_ERR,
DATABASE_ERR,
TOO_LARGE_ERR,
QUOTA_ERR,
TIMEOUT_ERR,
SYNTAX_ERR
message
A description of the error
error not considered by any other error codes
internal error of the database
the result set is too large
the db now exceeds the storage space of the app
ā€¢ā€Æ the statement is not sintactically correct
ā€¢ā€Æ the number of parameters does not match with
placeholders
no reasonable time to get the lock for the transition
Error Code Example
...
tx.executeSql(ā€˜SELECT * FROM USERā€˜,[], success, error);
}
function error(err) {
console.log(err.code);
}
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
Indexed DB
It tries to combine Web Storage and WebSQL
You can save data as key/value pairs
You can deļ¬ne multiple DBs
Good Performance
data is indexed
asynchronous Ć ļƒ  it does not block the UI
Indexed DB
An Indexed DB is a collection of object stores
You can drop objects into the stores
You can see a store as a big SQL table with only key/value pairs
Ć ļƒ  you donā€™t need to deļ¬ne a schema upfront
IndexedDB !== mobile storage
still not fully supported by iOS
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
File System Access
It allows you to read, write and navigate ļ¬le system hierarchies
It is fundamental for managing and storing large ļ¬les and binary
content on the client-side
File System Access Workļ¬‚ow
1.ā€Æ request ļ¬le system access
ā€“ā€Æ persistent or temporary ļ¬le system
2.ā€Æ then you can perform CRUD operations for both ļ¬les and
folders:
ā€“ā€Æ Create
ā€“ā€Æ Read
ā€“ā€Æ Update
ā€“ā€Æ Delete
Request File System
requestFileSystem(type, size, successCb, [errorCb])
type
LocalFileSystem.TEMPORARY
LocalFileSystem .PERSISTENT
size
size in bytes the app will require for storage
successCb
success callback, its argument is a FileSystem object
ErrorCb
error callback, its argument is a FileError object
Temporary VS Persistent
Temporary
the ļ¬les stored by the app can be deleted at the browserā€™s
discretionĀ 
Ć ļƒ  no guarantee of persistence
Persistent
cannot be deleted by the browser without authorization by the
app
Local File System Example
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0,
onSuccess,
onError);
function onSuccess(fileSystem) {
console.log(fileSystem.name);
}
leave it to zero, Apache Cordova will take care of it
File System
The FileSystem object has 2 properties:
name
the name of the ļ¬le system
it is unique across the list of exposed ļ¬le systems
root
the DirectoryEntry object representing the root folder of the
ļ¬le system
Resolving a File URI
window.resolveLocalFileSystemURI
retrieve a DirectoryEntryĀ or FileEntryĀ using a URI
window.resolveLocalFileSystemURI(
"file:///userImg.png", onSuccess, onError);
function onSuccess(fileEntry) {
console.log(fileEntry.name);
}
Important directories
Entities
FileEntry
DirectoryEntry
File
FileReader
FileWriter
DirectoryReader
The real objects
Descriptor
Writing & Reading objects
File Entry
It represents a ļ¬le on a ļ¬le system
isFile (boolean)
Always true
isDirectory (boolean)
Always false
name (DOMString)
the name of the FileEntry, excluding the pathĀ 
fullPath (DOMString)
the full absolute path from the root
File Entry Methods
getMetadata(success, fail)
Look up metadata about a ļ¬le
setMetadata(success, fail, metadataObject)
Sets the metadata of the ļ¬le
moveTo(parentEntry, newName, success, fail)
Move a ļ¬le to a different location on the ļ¬le system
copyTo(parentEntry, newName, success, fail)
Copy a ļ¬le to a different location on the ļ¬le system
toURL()
Return a URL that can be used to locate a ļ¬le
File Entry Methods
remove(success, fail)
Delete a ļ¬le
getParent(success, fail)
Look up the parent directory
createWriter(success, fail)
Creates aĀ FileWriterĀ object that can be used to write to a ļ¬le
ļ¬le(success, fail)
Creates aĀ File object containing ļ¬le properties
File
It contains attributes of a single ļ¬le
name (DOMString)
The name of the ļ¬le
fullPath (DOMString)
The full path of the ļ¬le including the ļ¬le name
type (DOMString)
The mime type of the ļ¬leĀ 
lastModiļ¬edDate (Date)
The last time the ļ¬le was modiļ¬ed
size (long) Ā 
The size of the ļ¬le in bytes
Directory Entry
It represents a directory on a ļ¬le system
It has the same properties of FileEntry
Directory Entry Methods
getMetadata(success, fail)
Look up metadata about a directory
setMetadata(success, fail, metadataObject)
Sets the metadata of the directory
moveTo(parentEntry, newName, success, fail)
Move a directory to a different location on the ļ¬le system
copyTo(parentEntry, newName, success, fail)
Copy a directory to a different location on the ļ¬le system
toURL()
Return a URL that can be used to locate a directory
Directory Entry Methods
getParent(success, fail)
Look up the parent directory
createReader()
Creates aĀ DirectoryReader object that can be used to read a
directory
getDirectory(path, options, success, fail)
Creates or looks up a directory
options:
create: (true | false)
exclusive: (true | false)
Directory Entry Methods
getFile(path, options, success, fail)
Create or look up a ļ¬le within the directory
options are used when the ļ¬le does not exist:
create Ć ļƒ  (true | false)
exclusive Ć ļƒ  (true | false)
removeRecursively(success, fail)
Delete a directory and all of its contents
File Reader
It is used to read the contents of a ļ¬le
Files can be read as:
ā€¢ā€Æ text
ā€¢ā€Æ base64 data encoded string
ā€¢ā€Æ binary string
ā€¢ā€Æ array buffer
You can also abort() a ļ¬le reading activity
You can register your own event listeners to receive the
following events:
loadstart, progress, load, loadend, error, abort
File Reader Example
entry.file(win, fail);
function win(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
console.log(evt.target.result);
};
reader.readAsText(file);
// reader.abort();
};
function fail(evt) {
console.log(error.code);
};
File Writer
It is used to write to a ļ¬le
The data to be written must be UTF-8 encoded
You can register your own event listeners to receive the
following events:
writestart, progress, write, writeend, error, abort
File Writer
AĀ FileWriter is created for a single ļ¬le
You can use it to write to a ļ¬le multiple times
Ć ļƒ ā€Æthe FileWriterĀ maintains the ļ¬le's position and length
attributes, so you can seek and write anywhere in the ļ¬le
By default, the FileWriter writes to the beginning of the ļ¬le (will
overwrite existing data)
Set the optional append boolean to true in theĀ FileWriter's
constructor to begin writing to the end of the ļ¬le
File Writer Methods
abort()
Aborts writing ļ¬le
seek(byte)
Moves the ļ¬le pointer to the byte speciļ¬ed.
truncate(length)
Shortens the ļ¬le to the length speciļ¬ed.
write(data)
Writes data to the ļ¬le
File Writer Example
entry.createWriter(win, fail);
function win(writer) {
writer.onwrite = function(evt) {
console.log(ā€œok");
};
writer.write(ā€œIvano Malavolta");
};
function fail(evt) {
// error management
};
Directory Reader
It is an object that lists ļ¬les and directories in a directory
It has only one method:
readEntries(success, fail)
Read the entries of the directory
Directory Reader Example
var directoryReader = dirEntry.createReader();
directoryReader.readEntries(success, fail);
function success(entries) {
var i;
for (i=0; i<entries.length; i++) {
console.log(entries[i].name);
}
}
function fail(error) {
console.log(error.code);
}
A Final Example
window.requestFileSystem(window.PERSISTENT, 0, initFS, error);
function initFS(fs) {
fs.root.getFile(ā€˜log.txt', {}, win, error);
}
function win(fileEntry) {
fileEntry.file(read, error);
}
function read(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
console.log(this.result);
};
reader.readAsText(file);
}
function error(err) { console.log(err);}
Looking for a ļ¬le and reading it
File upload
Upload ļ¬les to a remote server via an HTTP multi-part POST
request
var fileURI; // the path of the file on the device
var server; // encoded URL of the server
var win; // success callback
var fail; // error callback
var options; // optional parameters (see next slide)
var trustAllHosts; // optional boolean parameter,
// true to accept all security certificates
var ft = new FileTransfer();
ft.upload(fileURI, encodeURI(server), win, fail, options);
File upload options
The FileUploadOptions can be used to specify additional
parameters to the upload script
var options = new FileUploadOptions();
options.fileKey="fileā€;
options.fileName= ā€œfileNameā€);
options.mimeType="text/plain";
ā€¦
File upload options
File upload result
A FileUploadResult object is passed to the success callback
Properties:
bytesSent: the number of bytes sent to the server
responseCode: The HTTP response code returned by the server
response: The HTTP response returned by the server as string
headers: the headers of the HTTP response by the server
not supported in iOS
not supported in iOS
File download
Downloads ļ¬les from a remote server via an HTTP GET request
var source; // URL of the file to be downloaded
var target; // full path of the file to be saved
var win; // success callback (takes FileEntry object)
var fail; // error callback
var options; // optional parameters (only headers)
var trustAllHosts; // optional boolean parameter,
// true to accept all security certificates
var ft = new FileTransfer();
ft.download(encodeURI(source),target, win, fail, options);
File transfer abort
Used to stop an on-going ļ¬le transfer
var ft = new FileTransfer();
ft.upload(fileURI, encodeURI(server), win, fail, options);
// perform some operation
ft.abort():
File transfer progress
Special callback activated every time a new piece of data is
transferred
ft.onprogress = function(progress) {
if (progressEvent.lengthComputable) {
console.log((progress.loaded / progress.total) + ā€œ%ā€);
} else {
console.log(ā€œprogressedā€);
}
};
ft.download(...); // the same works for upload
File transfer error
The FileTransferError object stores information about an error
occurred during a ļ¬le transfer (either upload or download)
Properties:
code: predeļ¬ned error code
source: URI of the source
target: URI of the target
http_status: HTTP status code from the server (if received)
FileTransferError.FILE_NOT_FOUND_ERR
FileTransferError.INVALID_URL_ERR
FileTransferError.CONNECTION_ERR
FileTransferError.ABORT_ERR
Roadmap
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
Considerations
You will likely use more than one API in combination
Ć ļƒ  Use the right API for the right job
Web Storage
ā€¢ā€Æ it is not transactional Ć ļƒ  race conditions
ā€¢ā€Æ very simple API, no schema
ā€¢ā€Æ only String data Ć ļƒ  performance issues for complex data due
to JSON serialization
ā€¢ā€Æ session storage will be cleared after the app is closed
ā€¢ā€Æ limited quota
Considerations
WebSQL
SQL-based Ć ļƒ  fast and efļ¬cient
transactional Ć ļƒ  more robust
asynchronous Ć ļƒ  does not block the UI
rigid data structure Ć ļƒ  data integrity vs agility
limited quota
Considerations
IndexedDB
simple data model Ć ļƒ  easy to use
transactional Ć ļƒ  more robust
asynchronous Ć ļƒ  does not block the UI
good search performance Ć ļƒ  indexed data
data is unstructured Ć ļƒ  integrity problems
limited quota
not fully supported by every platform (e.g., iOS)
Considerations
File System
asynchronous Ć ļƒ  does not block the UI
not transactional
indexing and search are not built-in Ć ļƒ  you have to implement
your lookup functions
unlimited quota Ć ļƒ  useful for images, videos, documents, etc.
Platforms support
About quotas...
Local Storage
~ 10Mb
Session Storage
~ 10Mb
WebSQL
~ 50-80Mb (depends on
the device)
Indexed DB
~ 50-80Mb (depends on
the device)
File system
unlimited
Native DB
unlimited
Exercises
Extend the previous exercises you developed about Frascati
events so that users can:
1.ā€Æ save a speciļ¬c event or ā€œenteā€ as favorited via local storage
2.ā€Æ deļ¬ne a dedicated ā€œFavoritesā€ view of the app;
3.ā€Æ deļ¬ne a WebSQL DB for storing events and ā€œentiā€;
ā€“ā€Æ here you can support a very limited subset of the data
4.ā€Æ deļ¬ne a data prefetcher that at the ļ¬rst launch of the app
saves all the data coming from the Rest API to the WEBSQL
database;
ā€“ā€Æ in the subsequent launches of the app, the data must come from
the WebSQL database, and not from the Rest API
Data:
http://www.ivanomalavolta.com/ļ¬les/data/frascatiEventi.json
http://www.ivanomalavolta.com/ļ¬les/data/frascatiEnti.json
References
http://cordova.apache.org/docs/en/edge
Contact
Ivano Malavolta |
Gran Sasso Science Institute
iivanoo
ivano.malavolta@gssi.infn.it
www.ivanomalavolta.com

More Related Content

What's hot

Smart Complaint System
Smart  Complaint SystemSmart  Complaint System
Smart Complaint SystemTrupti Thakre
Ā 
Table Reservation System
Table Reservation SystemTable Reservation System
Table Reservation SystemSagar Singh
Ā 
Blood Bank System Peroject (website) Full Document
 Blood Bank System Peroject (website) Full Document  Blood Bank System Peroject (website) Full Document
Blood Bank System Peroject (website) Full Document DAV.PG COLLAGE
Ā 
Final project se
Final project seFinal project se
Final project sehira akram
Ā 
Canteen management
Canteen managementCanteen management
Canteen managementOmkar Majukar
Ā 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
Ā 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
Ā 
Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Adam Mukharil Bachtiar
Ā 
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģž
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģžCeleryģ˜ ė¹›ź³¼ ź·øė¦¼ģž
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģžMinyoung Jeong
Ā 
Advanced java
Advanced java Advanced java
Advanced java NA
Ā 
Music management system
Music management system  Music management system
Music management system Nilesh Padwal
Ā 
Restaurant Management System
Restaurant Management SystemRestaurant Management System
Restaurant Management SystemJuliasmith1985
Ā 
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģžDonghyeok Kang
Ā 
Fungsi fungsi pada php - pemrograman php my sql
Fungsi fungsi pada php - pemrograman php my sqlFungsi fungsi pada php - pemrograman php my sql
Fungsi fungsi pada php - pemrograman php my sqlDeka M Wildan
Ā 
ER diagrams for blood bank management system
ER diagrams for blood bank management systemER diagrams for blood bank management system
ER diagrams for blood bank management systemSoham Nanekar
Ā 
Hostel Management system Report
Hostel Management system ReportHostel Management system Report
Hostel Management system ReportPrasoon Rawat
Ā 
Online restaurant management system
Online restaurant management systemOnline restaurant management system
Online restaurant management systemAmal Jose
Ā 
Report on Smart Blood Bank project
Report on Smart Blood Bank projectReport on Smart Blood Bank project
Report on Smart Blood Bank projectk Tarun
Ā 

What's hot (20)

Smart Complaint System
Smart  Complaint SystemSmart  Complaint System
Smart Complaint System
Ā 
Table Reservation System
Table Reservation SystemTable Reservation System
Table Reservation System
Ā 
Blood Bank System Peroject (website) Full Document
 Blood Bank System Peroject (website) Full Document  Blood Bank System Peroject (website) Full Document
Blood Bank System Peroject (website) Full Document
Ā 
Final project se
Final project seFinal project se
Final project se
Ā 
Canteen management
Canteen managementCanteen management
Canteen management
Ā 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Ā 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Ā 
Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)
Ā 
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģž
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģžCeleryģ˜ ė¹›ź³¼ ź·øė¦¼ģž
Celeryģ˜ ė¹›ź³¼ ź·øė¦¼ģž
Ā 
Advanced java
Advanced java Advanced java
Advanced java
Ā 
Music management system
Music management system  Music management system
Music management system
Ā 
Restaurant Management System
Restaurant Management SystemRestaurant Management System
Restaurant Management System
Ā 
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž
[ģ œ1ķšŒ ė£Øģ”¬ ķ•œźø€ė¶„ģ„źø° źø°ģˆ ģ„øėÆøė‚˜] solrė”œ ė‚˜ė§Œģ˜ ź²€ģƒ‰ģ—”ģ§„ģ„ ė§Œė“¤ģ–“ė³“ģž
Ā 
Fungsi fungsi pada php - pemrograman php my sql
Fungsi fungsi pada php - pemrograman php my sqlFungsi fungsi pada php - pemrograman php my sql
Fungsi fungsi pada php - pemrograman php my sql
Ā 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
Ā 
ER diagrams for blood bank management system
ER diagrams for blood bank management systemER diagrams for blood bank management system
ER diagrams for blood bank management system
Ā 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
Ā 
Hostel Management system Report
Hostel Management system ReportHostel Management system Report
Hostel Management system Report
Ā 
Online restaurant management system
Online restaurant management systemOnline restaurant management system
Online restaurant management system
Ā 
Report on Smart Blood Bank project
Report on Smart Blood Bank projectReport on Smart Blood Bank project
Report on Smart Blood Bank project
Ā 

Viewers also liked

Apache Cordova APIs version 4.3.0
Apache Cordova APIs version 4.3.0 Apache Cordova APIs version 4.3.0
Apache Cordova APIs version 4.3.0 Ivano Malavolta
Ā 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JSIvano Malavolta
Ā 
Mobile Apps Development: Technological strategies and Monetization
Mobile Apps Development: Technological strategies and MonetizationMobile Apps Development: Technological strategies and Monetization
Mobile Apps Development: Technological strategies and MonetizationIvano Malavolta
Ā 
Mobile geolocation and mapping
Mobile geolocation and mappingMobile geolocation and mapping
Mobile geolocation and mappingIvano Malavolta
Ā 
The Mobile ecosystem, Context & Strategies
The Mobile ecosystem, Context & StrategiesThe Mobile ecosystem, Context & Strategies
The Mobile ecosystem, Context & StrategiesIvano Malavolta
Ā 
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device CapabilitiesPhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device CapabilitiesIvano Malavolta
Ā 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile appsIvano Malavolta
Ā 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local StorageIvano Malavolta
Ā 
UI Design Patterns for Mobile Apps
UI Design Patterns for Mobile AppsUI Design Patterns for Mobile Apps
UI Design Patterns for Mobile AppsIvano Malavolta
Ā 
Mobile Applications Development - Lecture 0 - Spring 2013
Mobile Applications Development - Lecture 0 - Spring 2013Mobile Applications Development - Lecture 0 - Spring 2013
Mobile Applications Development - Lecture 0 - Spring 2013Ivano Malavolta
Ā 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile appsIvano Malavolta
Ā 
[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigmsIvano Malavolta
Ā 
Mobile Applications Development - Lecture 0
Mobile Applications Development - Lecture 0Mobile Applications Development - Lecture 0
Mobile Applications Development - Lecture 0Ivano Malavolta
Ā 
Design patterns for mobile apps
Design patterns for mobile appsDesign patterns for mobile apps
Design patterns for mobile appsIvano Malavolta
Ā 
UI design for mobile apps
UI design for mobile appsUI design for mobile apps
UI design for mobile appsIvano Malavolta
Ā 
Sitemaps & Wireframing
Sitemaps & WireframingSitemaps & Wireframing
Sitemaps & WireframingIvano Malavolta
Ā 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for MobileIvano Malavolta
Ā 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architectureIvano Malavolta
Ā 

Viewers also liked (20)

Apache Cordova APIs version 4.3.0
Apache Cordova APIs version 4.3.0 Apache Cordova APIs version 4.3.0
Apache Cordova APIs version 4.3.0
Ā 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Ā 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
Ā 
Mobile Apps Development: Technological strategies and Monetization
Mobile Apps Development: Technological strategies and MonetizationMobile Apps Development: Technological strategies and Monetization
Mobile Apps Development: Technological strategies and Monetization
Ā 
Mobile geolocation and mapping
Mobile geolocation and mappingMobile geolocation and mapping
Mobile geolocation and mapping
Ā 
The Mobile ecosystem, Context & Strategies
The Mobile ecosystem, Context & StrategiesThe Mobile ecosystem, Context & Strategies
The Mobile ecosystem, Context & Strategies
Ā 
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device CapabilitiesPhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
Ā 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
Ā 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
Ā 
UI Design Patterns for Mobile Apps
UI Design Patterns for Mobile AppsUI Design Patterns for Mobile Apps
UI Design Patterns for Mobile Apps
Ā 
Mobile Applications Development - Lecture 0 - Spring 2013
Mobile Applications Development - Lecture 0 - Spring 2013Mobile Applications Development - Lecture 0 - Spring 2013
Mobile Applications Development - Lecture 0 - Spring 2013
Ā 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
Ā 
[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms
Ā 
Mobile Applications Development - Lecture 0
Mobile Applications Development - Lecture 0Mobile Applications Development - Lecture 0
Mobile Applications Development - Lecture 0
Ā 
Design patterns for mobile apps
Design patterns for mobile appsDesign patterns for mobile apps
Design patterns for mobile apps
Ā 
UI design for mobile apps
UI design for mobile appsUI design for mobile apps
UI design for mobile apps
Ā 
PhoneGap
PhoneGapPhoneGap
PhoneGap
Ā 
Sitemaps & Wireframing
Sitemaps & WireframingSitemaps & Wireframing
Sitemaps & Wireframing
Ā 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for Mobile
Ā 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture
Ā 

Similar to Local data storage for mobile apps

Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
Ā 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applicationsjeromevdl
Ā 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
Ā 
Real World MVC
Real World MVCReal World MVC
Real World MVCJames Johnson
Ā 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPSxoopsproject
Ā 
Hibernate
Hibernate Hibernate
Hibernate Sunil OS
Ā 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed versionBruce McPherson
Ā 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationPriyobroto Ghosh (Mule ESB Certified)
Ā 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
Ā 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.pptDrMeenakshiS
Ā 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NETOm Vikram Thapa
Ā 
Play 2.0
Play 2.0Play 2.0
Play 2.0elizhender
Ā 
Practical OData
Practical ODataPractical OData
Practical ODataVagif Abilov
Ā 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code FirstJames Johnson
Ā 
Global objects in Node.pdf
Global objects in Node.pdfGlobal objects in Node.pdf
Global objects in Node.pdfSudhanshiBakre1
Ā 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database JonesJohn David Duncan
Ā 

Similar to Local data storage for mobile apps (20)

Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
Ā 
Local Storage
Local StorageLocal Storage
Local Storage
Ā 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applications
Ā 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
Ā 
Real World MVC
Real World MVCReal World MVC
Real World MVC
Ā 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPS
Ā 
Hibernate
Hibernate Hibernate
Hibernate
Ā 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
Ā 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
Ā 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
Ā 
Php summary
Php summaryPhp summary
Php summary
Ā 
Servlets
ServletsServlets
Servlets
Ā 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
Ā 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NET
Ā 
Play 2.0
Play 2.0Play 2.0
Play 2.0
Ā 
Practical OData
Practical ODataPractical OData
Practical OData
Ā 
La sql
La sqlLa sql
La sql
Ā 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
Ā 
Global objects in Node.pdf
Global objects in Node.pdfGlobal objects in Node.pdf
Global objects in Node.pdf
Ā 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
Ā 

More from Ivano Malavolta

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Ivano Malavolta
Ā 
The H2020 experience
The H2020 experienceThe H2020 experience
The H2020 experienceIvano Malavolta
Ā 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)Ivano Malavolta
Ā 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green ITIvano Malavolta
Ā 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Ivano Malavolta
Ā 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]Ivano Malavolta
Ā 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Ivano Malavolta
Ā 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Ivano Malavolta
Ā 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Ivano Malavolta
Ā 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Ivano Malavolta
Ā 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Ivano Malavolta
Ā 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Ivano Malavolta
Ā 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Ivano Malavolta
Ā 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Ivano Malavolta
Ā 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile developmentIvano Malavolta
Ā 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architecturesIvano Malavolta
Ā 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design LanguageIvano Malavolta
Ā 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languagesIvano Malavolta
Ā 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software ArchitectureIvano Malavolta
Ā 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineeringIvano Malavolta
Ā 

More from Ivano Malavolta (20)

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Ā 
The H2020 experience
The H2020 experienceThe H2020 experience
The H2020 experience
Ā 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Ā 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green IT
Ā 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Ā 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Ā 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Ā 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Ā 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Ā 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ā 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Ā 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Ā 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Ā 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...
Ā 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile development
Ā 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architectures
Ā 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language
Ā 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languages
Ā 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture
Ā 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering
Ā 

Recently uploaded

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
Ā 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
Ā 
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelDeepika Singh
Ā 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
Ā 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vƔzquez
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
Ā 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
Ā 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
Ā 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
Ā 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
Ā 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
Ā 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
Ā 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
Ā 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
Ā 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Ā 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
Ā 
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Ā 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Ā 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
Ā 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Ā 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Ā 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
Ā 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
Ā 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Ā 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Ā 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
Ā 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Ā 

Local data storage for mobile apps

  • 1. Gran Sasso Science Institute Ivano Malavolta Local Storage
  • 3. Local storage and ļ¬le system access There are 4 ways to store data locally in Cordova: ā€¢ā€Æ Web storage ā€¢ā€Æ Local Storage ā€¢ā€Æ Session Storage ā€¢ā€Æ WebSQL ā€¢ā€Æ Indexed DB ā€¢ā€Æ File System Access Web storage, WebSQL, and IndexedDB conform to W3C speciļ¬cations and are provided by the browser itself File system access API conforms to its corresponding W3C speciļ¬cation
  • 4. Web Storage LocalStorage stores data in key/value pairs persists across browser sessions SessionStorage stores data in key/value pairs data is erased when a browser session ends
  • 5. WebSQL relational DB support for tables creation, insert, update, ā€¦ transactional persists across browser sessions
  • 6. WebSQL It provides you a structured SQL relational database You have to setup a DB schema You can then perform classical SQL queries tx.executeSql(ā€˜SELECT Ā * Ā FROM Ā Userā€™, Ā [], Ā  Ā  Ā  Ā function(tx, Ā result) Ā { Ā  Ā  Ā  Ā  Ā // Ā callback Ā code Ā  }); Ā 
  • 7. IndexedDB ā€¢ā€Æ It combines Web Storage and WebSQL ā€¢ā€Æ You can save data as key/value pairs ā€¢ā€Æ You can deļ¬ne multiple DBs ā€¢ā€Æ Good Performance ā€“ā€Æ data is indexed ā€“ā€Æ Asynchronous Ć ļƒ  it does not block the UI You can see a store as a big SQL table with only key/value pairs Ć ļƒ  you donā€™t need to deļ¬ne a schema upfront
  • 8. File System ā€¢ā€Æ you can access ļ¬les locally to your app ā€¢ā€Æ supports main FS operation ā€“ā€Æ creation, move, delete, rename, etc. ā€¢ā€Æ it is not transactional ā€¢ā€Æ persists across browser sessions
  • 10. Web Storage It is based on a single persistent object called localStorage You can set values by calling window.localStorage.setItem(ā€œnameā€, ā€œIvanoā€); You can get values back by calling var name = window.localStorage.getItem(ā€œnameā€);
  • 11. Supported Methods .key(0) Returns the name of the key at the position speciļ¬ed .getItem(ā€œkeyā€) Returns the item identiļ¬ed by it's key .setItem(ā€œkeyā€, ā€œvalueā€) Saves and item at the key provided .removeItem(ā€œkeyā€) Removes the item identiļ¬ed by it's key .clear() Removes all the key-value pairs
  • 12. Complex Objects Current implementations support only string-to-string mappings Ć ļƒ ā€Æ you can store only strings Ć ļƒ ā€Æ keys can be only strings You can use JSON serialization if you need to store complex data structures
  • 13. Example of JSON Serialization // simple class declaration function Person(name, surname) { this.name = name; this.surname = surname; } // object creation var user = new Person(ā€˜Ivanoā€™, ā€˜Malavoltaā€™); // object serialization window.localStorage.setItem(ā€œuserā€, JSON.stringify(user)); // object retrieval var current = JSON.parse(window.localStorage.getItem(ā€œuserā€));
  • 14. Checking Existence You can simply check if the needed element is == null if (window.localStorage.getItem(ā€œuserā€)) { // there is an object in user } else { // the user key does not have any value }
  • 15. Selecting elements In this case you have to manually iterate on elements var users = [...]; // array of Person objects window.localStorage.setItem(ā€œusersā€, JSON.stringify(users)); var allUsers = JSON.parse(window.localStorage.getItem(ā€œusersā€)); var ivanos = []; for(var i=0; i<allUsers.length; i++) { if(allUsers[i].name == ā€˜Ivanoā€™) ivanos.push(allUsers[i]); }
  • 16. Counting Elements Also in this case, we have to do it manually var usersNumber = JSON.parse(window.localStorage.getItem(ā€œusersā€œ)).length;
  • 17. Session Storage Session Storage provides the same interface as Local Storage Ć ļƒ  you can call the same methods but Session Storage is cleared between app launches
  • 19. WebSQL It provides you a structured SQL relational database You have to setup a DB schema You can then perform classical SQL queries tx.executeSql("SELECT * FROM Userā€œ, [], function(tx, result) { // callback code });
  • 20. Opening a DB Done via a dedicated function var db = openDatabase(ā€˜Test', ā€˜1.0', ā€˜Test DB', 100000); It creates a new SQLite DB and returns a new Database object The Database object will be used to manipulate the data
  • 21. Opening a DB: syntax openDatabase(name, version, displayname, size); name the name of the DB version the version of the DB displayname the display name of the DB size the size of the DB in bytes
  • 22. Database It allows to manipulate the data via 2 methods: changeVersion atomically verify the version number and change it db.changeVersion("1.0", "1.1"); transaction performs a DB transaction
  • 23. Transactions It allow you to execute SQL statements against theĀ DB db.transaction(queries, error, success); 3 functions as parameters: queries : contains the queries to be performed error : executed if the transaction results in an error success : executed if the transaction terminates correctly
  • 25. executeSql It is the method that performs a SQL statement The user can build up a database transaction by calling the executeSql method multiple times function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS USER'); tx.executeSql('CREATE TABLE IF NOT EXISTS USER (id unique, name, surname)'); tx.executeSql('INSERT INTO USER(id, name, surname) VALUES (1, ?, ?)ā€˜, [ā€œIvanoā€œ, ā€œMalavoltaā€œ], success, error); }
  • 26. Result Sets When the executeSql method is called, it will invoke it's callback with a SQLResultSet parameter It has 3 properties: insertId the ID of the row that has been inserted rowsAffected the number of rows changed by the SQL statement rows the data returned from a SQL select statement rows is an object of type SQLResultSetListĀ 
  • 27. Results Sets Example ... tx.executeSql('INSERT INTO USER(id, name,surname) VALUES (5, ?, ?)ā€˜, [ā€œIvanoā€œ, ā€œMalavoltaā€œ], success, error); } function success(tx, results) { var affected = results.rowsAffected(); // 1 } function error(err) { // code for managing the error }
  • 28. Result Set Lists It contains the data returned from a SQL Select statement length the number of rows returned by the SQL query Ā  item(index) returns the row at the speciļ¬ed index represented by a JavaScript object
  • 29. Result Set List Example ... tx.executeSql(ā€˜SELECT * FROM USERā€˜, [], success, error); } function success(tx, results) { var size = results.rows.length; for (var i=0; i<size; i++){ console.log(results.rows.item(i).name); } }
  • 30. Errors It contains information about an occurred error code A predeļ¬ned error code es. UNKNOWN_ERR, DATABASE_ERR, TOO_LARGE_ERR, QUOTA_ERR, TIMEOUT_ERR, SYNTAX_ERR message A description of the error error not considered by any other error codes internal error of the database the result set is too large the db now exceeds the storage space of the app ā€¢ā€Æ the statement is not sintactically correct ā€¢ā€Æ the number of parameters does not match with placeholders no reasonable time to get the lock for the transition
  • 31. Error Code Example ... tx.executeSql(ā€˜SELECT * FROM USERā€˜,[], success, error); } function error(err) { console.log(err.code); }
  • 33. Indexed DB It tries to combine Web Storage and WebSQL You can save data as key/value pairs You can deļ¬ne multiple DBs Good Performance data is indexed asynchronous Ć ļƒ  it does not block the UI
  • 34. Indexed DB An Indexed DB is a collection of object stores You can drop objects into the stores You can see a store as a big SQL table with only key/value pairs Ć ļƒ  you donā€™t need to deļ¬ne a schema upfront
  • 35. IndexedDB !== mobile storage still not fully supported by iOS
  • 37. File System Access It allows you to read, write and navigate ļ¬le system hierarchies It is fundamental for managing and storing large ļ¬les and binary content on the client-side
  • 38. File System Access Workļ¬‚ow 1.ā€Æ request ļ¬le system access ā€“ā€Æ persistent or temporary ļ¬le system 2.ā€Æ then you can perform CRUD operations for both ļ¬les and folders: ā€“ā€Æ Create ā€“ā€Æ Read ā€“ā€Æ Update ā€“ā€Æ Delete
  • 39. Request File System requestFileSystem(type, size, successCb, [errorCb]) type LocalFileSystem.TEMPORARY LocalFileSystem .PERSISTENT size size in bytes the app will require for storage successCb success callback, its argument is a FileSystem object ErrorCb error callback, its argument is a FileError object
  • 40. Temporary VS Persistent Temporary the ļ¬les stored by the app can be deleted at the browserā€™s discretionĀ  Ć ļƒ  no guarantee of persistence Persistent cannot be deleted by the browser without authorization by the app
  • 41. Local File System Example window.requestFileSystem( LocalFileSystem.PERSISTENT, 0, onSuccess, onError); function onSuccess(fileSystem) { console.log(fileSystem.name); } leave it to zero, Apache Cordova will take care of it
  • 42. File System The FileSystem object has 2 properties: name the name of the ļ¬le system it is unique across the list of exposed ļ¬le systems root the DirectoryEntry object representing the root folder of the ļ¬le system
  • 43. Resolving a File URI window.resolveLocalFileSystemURI retrieve a DirectoryEntryĀ or FileEntryĀ using a URI window.resolveLocalFileSystemURI( "file:///userImg.png", onSuccess, onError); function onSuccess(fileEntry) { console.log(fileEntry.name); }
  • 46. File Entry It represents a ļ¬le on a ļ¬le system isFile (boolean) Always true isDirectory (boolean) Always false name (DOMString) the name of the FileEntry, excluding the pathĀ  fullPath (DOMString) the full absolute path from the root
  • 47. File Entry Methods getMetadata(success, fail) Look up metadata about a ļ¬le setMetadata(success, fail, metadataObject) Sets the metadata of the ļ¬le moveTo(parentEntry, newName, success, fail) Move a ļ¬le to a different location on the ļ¬le system copyTo(parentEntry, newName, success, fail) Copy a ļ¬le to a different location on the ļ¬le system toURL() Return a URL that can be used to locate a ļ¬le
  • 48. File Entry Methods remove(success, fail) Delete a ļ¬le getParent(success, fail) Look up the parent directory createWriter(success, fail) Creates aĀ FileWriterĀ object that can be used to write to a ļ¬le ļ¬le(success, fail) Creates aĀ File object containing ļ¬le properties
  • 49. File It contains attributes of a single ļ¬le name (DOMString) The name of the ļ¬le fullPath (DOMString) The full path of the ļ¬le including the ļ¬le name type (DOMString) The mime type of the ļ¬leĀ  lastModiļ¬edDate (Date) The last time the ļ¬le was modiļ¬ed size (long) Ā  The size of the ļ¬le in bytes
  • 50. Directory Entry It represents a directory on a ļ¬le system It has the same properties of FileEntry
  • 51. Directory Entry Methods getMetadata(success, fail) Look up metadata about a directory setMetadata(success, fail, metadataObject) Sets the metadata of the directory moveTo(parentEntry, newName, success, fail) Move a directory to a different location on the ļ¬le system copyTo(parentEntry, newName, success, fail) Copy a directory to a different location on the ļ¬le system toURL() Return a URL that can be used to locate a directory
  • 52. Directory Entry Methods getParent(success, fail) Look up the parent directory createReader() Creates aĀ DirectoryReader object that can be used to read a directory getDirectory(path, options, success, fail) Creates or looks up a directory options: create: (true | false) exclusive: (true | false)
  • 53. Directory Entry Methods getFile(path, options, success, fail) Create or look up a ļ¬le within the directory options are used when the ļ¬le does not exist: create Ć ļƒ  (true | false) exclusive Ć ļƒ  (true | false) removeRecursively(success, fail) Delete a directory and all of its contents
  • 54. File Reader It is used to read the contents of a ļ¬le Files can be read as: ā€¢ā€Æ text ā€¢ā€Æ base64 data encoded string ā€¢ā€Æ binary string ā€¢ā€Æ array buffer You can also abort() a ļ¬le reading activity You can register your own event listeners to receive the following events: loadstart, progress, load, loadend, error, abort
  • 55. File Reader Example entry.file(win, fail); function win(file) { var reader = new FileReader(); reader.onloadend = function(evt) { console.log(evt.target.result); }; reader.readAsText(file); // reader.abort(); }; function fail(evt) { console.log(error.code); };
  • 56. File Writer It is used to write to a ļ¬le The data to be written must be UTF-8 encoded You can register your own event listeners to receive the following events: writestart, progress, write, writeend, error, abort
  • 57. File Writer AĀ FileWriter is created for a single ļ¬le You can use it to write to a ļ¬le multiple times Ć ļƒ ā€Æthe FileWriterĀ maintains the ļ¬le's position and length attributes, so you can seek and write anywhere in the ļ¬le By default, the FileWriter writes to the beginning of the ļ¬le (will overwrite existing data) Set the optional append boolean to true in theĀ FileWriter's constructor to begin writing to the end of the ļ¬le
  • 58. File Writer Methods abort() Aborts writing ļ¬le seek(byte) Moves the ļ¬le pointer to the byte speciļ¬ed. truncate(length) Shortens the ļ¬le to the length speciļ¬ed. write(data) Writes data to the ļ¬le
  • 59. File Writer Example entry.createWriter(win, fail); function win(writer) { writer.onwrite = function(evt) { console.log(ā€œok"); }; writer.write(ā€œIvano Malavolta"); }; function fail(evt) { // error management };
  • 60. Directory Reader It is an object that lists ļ¬les and directories in a directory It has only one method: readEntries(success, fail) Read the entries of the directory
  • 61. Directory Reader Example var directoryReader = dirEntry.createReader(); directoryReader.readEntries(success, fail); function success(entries) { var i; for (i=0; i<entries.length; i++) { console.log(entries[i].name); } } function fail(error) { console.log(error.code); }
  • 62. A Final Example window.requestFileSystem(window.PERSISTENT, 0, initFS, error); function initFS(fs) { fs.root.getFile(ā€˜log.txt', {}, win, error); } function win(fileEntry) { fileEntry.file(read, error); } function read(file) { var reader = new FileReader(); reader.onloadend = function(e) { console.log(this.result); }; reader.readAsText(file); } function error(err) { console.log(err);} Looking for a ļ¬le and reading it
  • 63. File upload Upload ļ¬les to a remote server via an HTTP multi-part POST request var fileURI; // the path of the file on the device var server; // encoded URL of the server var win; // success callback var fail; // error callback var options; // optional parameters (see next slide) var trustAllHosts; // optional boolean parameter, // true to accept all security certificates var ft = new FileTransfer(); ft.upload(fileURI, encodeURI(server), win, fail, options);
  • 64. File upload options The FileUploadOptions can be used to specify additional parameters to the upload script var options = new FileUploadOptions(); options.fileKey="fileā€; options.fileName= ā€œfileNameā€); options.mimeType="text/plain"; ā€¦
  • 66. File upload result A FileUploadResult object is passed to the success callback Properties: bytesSent: the number of bytes sent to the server responseCode: The HTTP response code returned by the server response: The HTTP response returned by the server as string headers: the headers of the HTTP response by the server not supported in iOS not supported in iOS
  • 67. File download Downloads ļ¬les from a remote server via an HTTP GET request var source; // URL of the file to be downloaded var target; // full path of the file to be saved var win; // success callback (takes FileEntry object) var fail; // error callback var options; // optional parameters (only headers) var trustAllHosts; // optional boolean parameter, // true to accept all security certificates var ft = new FileTransfer(); ft.download(encodeURI(source),target, win, fail, options);
  • 68. File transfer abort Used to stop an on-going ļ¬le transfer var ft = new FileTransfer(); ft.upload(fileURI, encodeURI(server), win, fail, options); // perform some operation ft.abort():
  • 69. File transfer progress Special callback activated every time a new piece of data is transferred ft.onprogress = function(progress) { if (progressEvent.lengthComputable) { console.log((progress.loaded / progress.total) + ā€œ%ā€); } else { console.log(ā€œprogressedā€); } }; ft.download(...); // the same works for upload
  • 70. File transfer error The FileTransferError object stores information about an error occurred during a ļ¬le transfer (either upload or download) Properties: code: predeļ¬ned error code source: URI of the source target: URI of the target http_status: HTTP status code from the server (if received) FileTransferError.FILE_NOT_FOUND_ERR FileTransferError.INVALID_URL_ERR FileTransferError.CONNECTION_ERR FileTransferError.ABORT_ERR
  • 72. Considerations You will likely use more than one API in combination Ć ļƒ  Use the right API for the right job Web Storage ā€¢ā€Æ it is not transactional Ć ļƒ  race conditions ā€¢ā€Æ very simple API, no schema ā€¢ā€Æ only String data Ć ļƒ  performance issues for complex data due to JSON serialization ā€¢ā€Æ session storage will be cleared after the app is closed ā€¢ā€Æ limited quota
  • 73. Considerations WebSQL SQL-based Ć ļƒ  fast and efļ¬cient transactional Ć ļƒ  more robust asynchronous Ć ļƒ  does not block the UI rigid data structure Ć ļƒ  data integrity vs agility limited quota
  • 74. Considerations IndexedDB simple data model Ć ļƒ  easy to use transactional Ć ļƒ  more robust asynchronous Ć ļƒ  does not block the UI good search performance Ć ļƒ  indexed data data is unstructured Ć ļƒ  integrity problems limited quota not fully supported by every platform (e.g., iOS)
  • 75. Considerations File System asynchronous Ć ļƒ  does not block the UI not transactional indexing and search are not built-in Ć ļƒ  you have to implement your lookup functions unlimited quota Ć ļƒ  useful for images, videos, documents, etc.
  • 77. About quotas... Local Storage ~ 10Mb Session Storage ~ 10Mb WebSQL ~ 50-80Mb (depends on the device) Indexed DB ~ 50-80Mb (depends on the device) File system unlimited Native DB unlimited
  • 78. Exercises Extend the previous exercises you developed about Frascati events so that users can: 1.ā€Æ save a speciļ¬c event or ā€œenteā€ as favorited via local storage 2.ā€Æ deļ¬ne a dedicated ā€œFavoritesā€ view of the app; 3.ā€Æ deļ¬ne a WebSQL DB for storing events and ā€œentiā€; ā€“ā€Æ here you can support a very limited subset of the data 4.ā€Æ deļ¬ne a data prefetcher that at the ļ¬rst launch of the app saves all the data coming from the Rest API to the WEBSQL database; ā€“ā€Æ in the subsequent launches of the app, the data must come from the WebSQL database, and not from the Rest API Data: http://www.ivanomalavolta.com/ļ¬les/data/frascatiEventi.json http://www.ivanomalavolta.com/ļ¬les/data/frascatiEnti.json
  • 80. Contact Ivano Malavolta | Gran Sasso Science Institute iivanoo ivano.malavolta@gssi.infn.it www.ivanomalavolta.com