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 file 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
specifications and are provided
by the browser itself
File system access API conforms to its
corresponding W3C specification
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 define 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 define a schema upfront
File System
•  you can access files 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 specified
.getItem(“key”)
Returns the item identified by it's key
.setItem(“key”, “value”)
Saves and item at the key provided
.removeItem(“key”)
Removes the item identified 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 specified 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 predefined 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 define 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 define 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 file system hierarchies
It is fundamental for managing and storing large files and binary
content on the client-side
File System Access Workflow
1.  request file system access
–  persistent or temporary file system
2.  then you can perform CRUD operations for both files 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 files 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 file system
it is unique across the list of exposed file systems
root
the DirectoryEntry object representing the root folder of the
file 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 file on a file 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 file
setMetadata(success, fail, metadataObject)
Sets the metadata of the file
moveTo(parentEntry, newName, success, fail)
Move a file to a different location on the file system
copyTo(parentEntry, newName, success, fail)
Copy a file to a different location on the file system
toURL()
Return a URL that can be used to locate a file
File Entry Methods
remove(success, fail)
Delete a file
getParent(success, fail)
Look up the parent directory
createWriter(success, fail)
Creates a FileWriter object that can be used to write to a file
file(success, fail)
Creates a File object containing file properties
File
It contains attributes of a single file
name (DOMString)
The name of the file
fullPath (DOMString)
The full path of the file including the file name
type (DOMString)
The mime type of the file 
lastModifiedDate (Date)
The last time the file was modified
size (long)  
The size of the file in bytes
Directory Entry
It represents a directory on a file 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 file system
copyTo(parentEntry, newName, success, fail)
Copy a directory to a different location on the file 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 file within the directory
options are used when the file 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 file
Files can be read as:
•  text
•  base64 data encoded string
•  binary string
•  array buffer
You can also abort() a file 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 file
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 file
You can use it to write to a file multiple times
à the FileWriter maintains the file's position and length
attributes, so you can seek and write anywhere in the file
By default, the FileWriter writes to the beginning of the file (will
overwrite existing data)
Set the optional append boolean to true in the FileWriter's
constructor to begin writing to the end of the file
File Writer Methods
abort()
Aborts writing file
seek(byte)
Moves the file pointer to the byte specified.
truncate(length)
Shortens the file to the length specified.
write(data)
Writes data to the file
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 files 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 file and reading it
File upload
Upload files 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 files 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 file 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 file transfer (either upload or download)
Properties:
code: predefined 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 efficient
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 specific event or “ente” as favorited via local storage
2.  define a dedicated “Favorites” view of the app;
3.  define a WebSQL DB for storing events and “enti”;
–  here you can support a very limited subset of the data
4.  define a data prefetcher that at the first 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/files/data/frascatiEventi.json
http://www.ivanomalavolta.com/files/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

Installing and configuring a dhcp on windows server 2016 step by step
Installing and configuring a dhcp on windows server 2016 step by stepInstalling and configuring a dhcp on windows server 2016 step by step
Installing and configuring a dhcp on windows server 2016 step by stepAhmed Abdelwahed
 
Introduction to linux ppt
Introduction to linux pptIntroduction to linux ppt
Introduction to linux pptOmi Vichare
 
1 introduction to windows server 2016
1  introduction to windows server 20161  introduction to windows server 2016
1 introduction to windows server 2016Hameda Hurmat
 
INTRODUCTION TO NETWORK OS
INTRODUCTION TO NETWORK OSINTRODUCTION TO NETWORK OS
INTRODUCTION TO NETWORK OSkinish kumar
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linuxVarnnit Jain
 
Network architecture - part-I
Network architecture - part-INetwork architecture - part-I
Network architecture - part-Icsk selva
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)Sri Prasanna
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsTrinity Dwarka
 
Big Data: Technical Introduction to BigSheets for InfoSphere BigInsights
Big Data:  Technical Introduction to BigSheets for InfoSphere BigInsightsBig Data:  Technical Introduction to BigSheets for InfoSphere BigInsights
Big Data: Technical Introduction to BigSheets for InfoSphere BigInsightsCynthia Saracco
 
Peer To Peer Networking
Peer To Peer NetworkingPeer To Peer Networking
Peer To Peer Networkingicanhasfay
 
Network operating systems
Network operating systems Network operating systems
Network operating systems Sachin Awasthi
 
Mcse notes
Mcse notesMcse notes
Mcse notesvrammn
 

What's hot (20)

Installing and configuring a dhcp on windows server 2016 step by step
Installing and configuring a dhcp on windows server 2016 step by stepInstalling and configuring a dhcp on windows server 2016 step by step
Installing and configuring a dhcp on windows server 2016 step by step
 
Introduction to linux ppt
Introduction to linux pptIntroduction to linux ppt
Introduction to linux ppt
 
1 introduction to windows server 2016
1  introduction to windows server 20161  introduction to windows server 2016
1 introduction to windows server 2016
 
INTRODUCTION TO NETWORK OS
INTRODUCTION TO NETWORK OSINTRODUCTION TO NETWORK OS
INTRODUCTION TO NETWORK OS
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
 
Operating system
Operating systemOperating system
Operating system
 
Ubuntu OS Presentation
Ubuntu OS PresentationUbuntu OS Presentation
Ubuntu OS Presentation
 
Network architecture - part-I
Network architecture - part-INetwork architecture - part-I
Network architecture - part-I
 
Dhcp ppt
Dhcp pptDhcp ppt
Dhcp ppt
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Big Data: Technical Introduction to BigSheets for InfoSphere BigInsights
Big Data:  Technical Introduction to BigSheets for InfoSphere BigInsightsBig Data:  Technical Introduction to BigSheets for InfoSphere BigInsights
Big Data: Technical Introduction to BigSheets for InfoSphere BigInsights
 
Peer To Peer Networking
Peer To Peer NetworkingPeer To Peer Networking
Peer To Peer Networking
 
Network operating systems
Network operating systems Network operating systems
Network operating systems
 
Presentation on operating system
 Presentation on operating system Presentation on operating system
Presentation on operating system
 
DNS (Domain Name System)
DNS (Domain Name System)DNS (Domain Name System)
DNS (Domain Name System)
 
Introduction to Ubuntu
Introduction to UbuntuIntroduction to Ubuntu
Introduction to Ubuntu
 
Dns server
Dns serverDns server
Dns server
 
Computer network
Computer networkComputer network
Computer network
 
Mcse notes
Mcse notesMcse notes
Mcse notes
 

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
 
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
 
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
 
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
 
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
 
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
 
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 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

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 

Local data storage for mobile apps

  • 1. Gran Sasso Science Institute Ivano Malavolta Local Storage
  • 3. Local storage and file 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 specifications and are provided by the browser itself File system access API conforms to its corresponding W3C specification
  • 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 define 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 define a schema upfront
  • 8. File System •  you can access files 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 specified .getItem(“key”) Returns the item identified by it's key .setItem(“key”, “value”) Saves and item at the key provided .removeItem(“key”) Removes the item identified 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 specified 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 predefined 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 define 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 define 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 file system hierarchies It is fundamental for managing and storing large files and binary content on the client-side
  • 38. File System Access Workflow 1.  request file system access –  persistent or temporary file system 2.  then you can perform CRUD operations for both files 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 files 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 file system it is unique across the list of exposed file systems root the DirectoryEntry object representing the root folder of the file 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 file on a file 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 file setMetadata(success, fail, metadataObject) Sets the metadata of the file moveTo(parentEntry, newName, success, fail) Move a file to a different location on the file system copyTo(parentEntry, newName, success, fail) Copy a file to a different location on the file system toURL() Return a URL that can be used to locate a file
  • 48. File Entry Methods remove(success, fail) Delete a file getParent(success, fail) Look up the parent directory createWriter(success, fail) Creates a FileWriter object that can be used to write to a file file(success, fail) Creates a File object containing file properties
  • 49. File It contains attributes of a single file name (DOMString) The name of the file fullPath (DOMString) The full path of the file including the file name type (DOMString) The mime type of the file  lastModifiedDate (Date) The last time the file was modified size (long)   The size of the file in bytes
  • 50. Directory Entry It represents a directory on a file 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 file system copyTo(parentEntry, newName, success, fail) Copy a directory to a different location on the file 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 file within the directory options are used when the file 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 file Files can be read as: •  text •  base64 data encoded string •  binary string •  array buffer You can also abort() a file 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 file 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 file You can use it to write to a file multiple times à the FileWriter maintains the file's position and length attributes, so you can seek and write anywhere in the file By default, the FileWriter writes to the beginning of the file (will overwrite existing data) Set the optional append boolean to true in the FileWriter's constructor to begin writing to the end of the file
  • 58. File Writer Methods abort() Aborts writing file seek(byte) Moves the file pointer to the byte specified. truncate(length) Shortens the file to the length specified. write(data) Writes data to the file
  • 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 files 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 file and reading it
  • 63. File upload Upload files 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 files 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 file 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 file transfer (either upload or download) Properties: code: predefined 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 efficient 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 specific event or “ente” as favorited via local storage 2.  define a dedicated “Favorites” view of the app; 3.  define a WebSQL DB for storing events and “enti”; –  here you can support a very limited subset of the data 4.  define a data prefetcher that at the first 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/files/data/frascatiEventi.json http://www.ivanomalavolta.com/files/data/frascatiEnti.json
  • 80. Contact Ivano Malavolta | Gran Sasso Science Institute iivanoo ivano.malavolta@gssi.infn.it www.ivanomalavolta.com