CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ......
Transcript of CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ......
![Page 1: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/1.jpg)
CS371m - Mobile Computing
Persistence - Web Based StorageCHECK OUT
https://developer.android.com/training/sync-adapters/index.html
![Page 2: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/2.jpg)
The Cloud ……….
2
![Page 3: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/3.jpg)
Backend
• No clear definition of backend
• front end - user interface
• backend - data, server, programs the user does not interact with directly
• With 1,000,000s of mobile and web apps …
• rise of Backend as a Service (Baas)
• Sometimes MBaaS, M for mobile
3
![Page 4: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/4.jpg)
Back End As a Service - May Provide:
• cloud storage of data
• integration with social networks
• push notifications
– server initiates communication, not the client
• messaging and chat functions
• user management
• user analysis tools
• abstractions for dealing with the backend4
![Page 5: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/5.jpg)
Clicker
• How many Mobile Backend as a Service providers exist?
A. 1 or 2
B. about 5
C. about 10
D. about 20
E. 30 or morehttps://github.com/relatedcode/ParseAlternatives
5
![Page 6: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/6.jpg)
MBaaS
6
![Page 7: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/7.jpg)
Some Examples of MBaas
• Parse
• Firebase (Google)
• Amazon Web Services
• Google Cloud Platform
• Heroku
• PythonAnywhere
• Rackspace Cloud
• BaasBox (Open Source)
• Usergrid (Open Source)
7
![Page 8: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/8.jpg)
8
![Page 9: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/9.jpg)
Examples of Using a MBaaS
• Parse
• www.parse.com
• various pricing models
• relatively easy to set up and use
• Going away1/28/2017
9
![Page 10: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/10.jpg)
Parse Set Up in AndroidStudio
1. request api key
2. Download Parse SDK
3. Unzip files
4. Create libs directory in app directory (select Project view)
5. Drag jar files to libs directory
10
![Page 11: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/11.jpg)
Parse Set Up in AndroidStudio
6. add dependencies to gradle build file under app
like so:
11
https://www.parse.com/apps/quickstart#parse_data/mobile/android/native/new
![Page 12: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/12.jpg)
Testing Parse
• Add permissions to manifest to access network state and use internet
• initialize Parse in onCreate method
• keys for account and app
12
![Page 13: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/13.jpg)
Testing Parse
• at the end of onCreate()• create and send a test object to Parse
• abstraction– handles doing this in the background,
off the UI thread13
![Page 14: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/14.jpg)
Result of Test
• JSON
– JavaScript Object Notation
14
![Page 15: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/15.jpg)
ParseObject
• Local representation of data (on the device) that can be saved and retrieved from the Parse
• String in constructor is class name– like a table in a data base
• put to add key - value pairs– String - Object
– keys must be alphanumerics
– like a column in the row15
![Page 16: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/16.jpg)
ParseObject
• saveInBackground method saves object to Parse in a background thread
• multiple options for saving– saveAll(List)
– saveEventually() - if server or network not available
– saveInBackground(SaveCallback)16
![Page 17: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/17.jpg)
Parse and RandomArt
• add ability to save equations
• save to parse database
• allow multiple users to save equations
• functionality to display a random equation others liked
• up and down votes
17
![Page 18: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/18.jpg)
onClick for Keep This
18
![Page 19: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/19.jpg)
onClick for Save Equation - cont.
19
ParseObject allowed addition of any key value pair.Keys must be Strings.
![Page 20: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/20.jpg)
saveEquation
• Makes a query to get the number of rows in the expression table
– uses another table with one row with one column (GACK, no auto increment function)
• callback method for completed query
• checks the count
• creates new ParseObject
• makes the index for this new expression the count (0 based indexing)
• saves the object and updates count object 20
![Page 21: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/21.jpg)
Parse Dashboard
• Examine data uploaded from apps
21
![Page 22: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/22.jpg)
demo Saving an Equation
22
![Page 23: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/23.jpg)
Get Random Saved Art
• When user presses button pick a random saved expression and render that image
• We just save the expression so we must recreate image
– time vs. space trade off
• check count of values and pick random index
23
![Page 24: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/24.jpg)
getRandomGoodArt
24
![Page 25: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/25.jpg)
callback object
• pull out the String from the returned object and build expression based on equation
25
![Page 26: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/26.jpg)
good one logcat
26
![Page 27: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/27.jpg)
More Parse
• Includes capability to do local data store– save objects on device, save to cloud later– abstracts away a lot of the details– Kyle Norton from Pariveda: "Assume you
WON'T be connected to the network."
• Parse objects meant to be "small"– less than 128 kb– not for images– Parse files for large pieces of data
• Past semesters many groups used Parse successfully
27
![Page 28: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/28.jpg)
28
FIREBASE
![Page 29: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/29.jpg)
Firebase
• Yet another Backend as a Service (Baas)
• Designed for web and mobile
• Founded in 2011
• Initial product was backend so websites could easily host chat as part of site
• discovered developers were sending non chat data (such as game state) via the tool
29
![Page 30: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/30.jpg)
Firebase for Android
• Devices with Android 4.0 (ice cream sandwich) or higher
• Google play services SDK– same as fused location
• Android Studio 1.5 or higher
• Your Android studio project and package name
• Firebase Assistant in Android Studio 2.2 or higher – Tools -> Firebase
30
![Page 31: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/31.jpg)
Firebase Project Set up
• Create Firebase project in console
• Just needs name and country
31
![Page 32: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/32.jpg)
Firebase Project Console
• After creating project, overview page:
32
![Page 33: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/33.jpg)
Firebase for Android Project
• Adding Firebase to Android app
• Need package name (easy)
• Debug signing certificate SHA-1 hash (for use of some Firebase features)
• Uses the keytool program included with Java
–"Manages a keystore (database) of cryptographic keys, X.509 certificate chains, and trusted certificates. " 33
![Page 34: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/34.jpg)
Adding Firebase to Android App
34
![Page 35: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/35.jpg)
Using keytool
• Varies from system to system
• need location of debug signing certificate
– created automatically when Android Studio installed
• typically, <USER>/.android/debugkeystore
35
![Page 36: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/36.jpg)
Debug Signing Certificate
36
• certificate not human readable
![Page 37: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/37.jpg)
Running keytool
• Specifics vary from system to system
37
![Page 38: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/38.jpg)
Firebase Config File for App
• After providing package name and SHA-1 fingerprint ...
• Firebase generates a JSON file named google-services.json specific for this project
–multiple projects / apps -> repeat steps
• Download and add file to project
38
![Page 39: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/39.jpg)
Firebase Config File for App
39
![Page 40: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/40.jpg)
google-services.json
40
![Page 41: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/41.jpg)
Update Gradle Files
41
![Page 42: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/42.jpg)
Firebase Capabilities
• Firebase has a host of capabilities
• User authorization
• database storage
• storage for larger files
• cloud messaging
• push notifications
• analytics
• hosting of web content
42
![Page 43: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/43.jpg)
Firebase Database
• With Parse offline, migrated Random Art database to Firebase
• The roots of the chat room are somewhat apparent
– lots of chat examples
– realtime updates
–emphasis on authorized users
43
![Page 44: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/44.jpg)
One More Setup Step
• To use Firebase databases in app, after previous setup steps:
44
![Page 45: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/45.jpg)
Firebase Database Rules
• Firebase database rules
• Defines:
• How data should be structured
• How data should be indexed
• When data can be read or written
• Who can read and write data
45
![Page 46: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/46.jpg)
Firebase Database Rules
46
![Page 47: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/47.jpg)
Hello Firebase
• In app, called from onCreate of Activity
47
![Page 48: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/48.jpg)
Result When App Run
• Immediately writes to database if network connections exists:
48
![Page 49: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/49.jpg)
Firebase database
• Not traditional tables
• "Everything is a JSON! tree"
• Children of main tree are like "tables" in traditional database
• Children of children are typically (but not always) like rows in a traditional table
49
![Page 50: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/50.jpg)
Random Art Data on Firebase
• equation count child to assign ids and pick random equation
• equation list with children for each equation
50
![Page 51: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/51.jpg)
Random Art
• App keeps track of current equation count
• First value from database and listener so whenever count changes, local copy is updated
51
![Page 52: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/52.jpg)
Random Art
• Keep references to parts of JSON tree
• Update values (equation count)
• add children (new, good equations)
• pull random children (old, good equations)
• In main Random Art Activity
52
![Page 53: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/53.jpg)
Random Art - Count Listener
53
![Page 54: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/54.jpg)
Random Art - Save Equation
• setValue method to add child
• Firebase data: String, Long, Double, Boolean, Map<String, Object>, List<Object>
• any custom object with 0 argument constructor and public getters for properties54
![Page 55: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/55.jpg)
Random Art - Get Equation
• Pick random child based on current number of equations
55
![Page 56: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/56.jpg)
JSON56
![Page 57: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/57.jpg)
JSON
• JavaScript Object Notation
• a way to represent JavaScript objects as Strings
• alternative to XML for passing data between servers and clients
• designed for data interchange format that humans can also read and write
57
![Page 58: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/58.jpg)
JSON Format
• Built on two structures
– collection of name-value pairs: a.k.a. objects, records, structs, etc.
– an ordered list of values: a.k.a. an array
• objects
58
![Page 59: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/59.jpg)
JSON Format
• arrays
• values
– string, number, object, array, true, false, null
59
![Page 61: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/61.jpg)
JSON Strings
61
![Page 62: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/62.jpg)
JSON Numbers
62
![Page 63: CS378 - Mobile ComputingCS371m - Mobile Computing Persistence - Web Based Storage CHECK OUT ... •Local representation of data (on the device) that can be saved and retrieved from](https://reader033.fdocuments.in/reader033/viewer/2022042312/5eda44b3b3745412b5710e82/html5/thumbnails/63.jpg)
JSON Examples
• value (String):
– "Round Rock"
• array:
– ["Round Rock", "Dallas", "Houston"]
• object
– {"height":70,"weight":165}
63