Persistence CS 344 Mobile App Development Robert Muller.

Slides:



Advertisements
Similar presentations
Integrating Facebook into iOS Apps 08/25/2011 North Atlanta iOS Developers Meetup Group Presentation.
Advertisements

Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
JSP and web applications
Cognos Web Services Business Intelligence. SOA SOA (Service Oriented Architecture) The SOA approach involves seven key principles: -- Coarse -grained.
CS 3800 Su 11 Beg. IOS Dev L4 Obj C part 1 CS 3800 Introduction to IOS programming Summer 2011 G. Zimmerman.
File System – Unix baed. An entry of Active File table: 1. Access Right: r/w/x 2. Process Count: no. of processes which are now referring to the file.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Persistence 2: SQLite CS 344 Mobile App Development Robert Muller.
Anatomy of an iPhone Application Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
IPhone Development Crash Course By Dylan Harris
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Suman B.K, iPhone Team Lead  Data Modelling  MVC-Design Patterns  Delegates & Notifications  Memory Management & Performance.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
Building + Consuming WebServices CF Style Kevin Penny MMCP (4.5/5/MX6)
Sen Wang 11/17/2011.  RFC  “Form-based File Upload in HTML” NOV 1995 
Memory Management and Automatic Reference Counting/ Copying Objects Archiving Copyright © 2012 by Yong-Gu Lee
Avro Apache Course: Distributed class Student ID: AM Name: Azzaya Galbazar
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
Applets Life Cycle Drawing and Event Handling Methods for UI Components Applet Capabilities Example.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Additional Topics. API Bindings Bindings Binding Native API’s Create Binding Project Drop Jar or.a Done.
Final Exam Review Closed book Closed laptop One sheet of notes permitted SE-0010 Dr. Mark L. Hornick 1.
SE-1020 Dr. Mark L. Hornick 1 File Input and Output.
Introduction to GATE Developer Ian Roberts. University of Sheffield NLP Overview The GATE component model (CREOLE) Documents, annotations and corpora.
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 16 Summer 2011.
1 Chapter 12: Form Builder Objects and Flexible Code.
Introduction to Objective-C and Xcode (Part 5) FA 175 Intro to Mobile App Development.
 Facebook Integration on iOS Phan Thanh Phat Huynh Thanh Van.
XRX Basic CRUDS Create, Read, Update and Delete and Search XML Data Date: May 2011 Dan McCreary President Dan McCreary & Associates
Course Summary Xcode & iPhone Simulator
Sounds, Images, and Text FA 172 Intro to Mobile App Development.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
A stream is a sequence of data. A stream is a flowing sequence of characters.
A brief introduction to doxygen. What does a compiler do?  A compiler ignores comments and processes the code.  What does doxygen do? –It ignores the.
Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID: Operating System Research Topic December, 2000.
The Controller in MVC of iOS CS4521. The controller in the MVC  Controller  Knows about model and view objects  The brains of the operation  Manages.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
More Objective-C Details FA 172 Intro to Mobile App Development.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Lec 5 Obj-C part 2 CS 3800 Introduction to IOS programming Lecture 5 Summer 2011.
OBJECTIVE C Kurt Ladendorf. General Knowledge  Super set of C  Smalltalk  Mainly used for iOS and other Apple development.
1 More About HTML Images and Links. 22 Objectives You will be able to Include images in your HTML page. Create links to other pages on your HTML page.
IOS Programming Medialogy, Semester 7, 2010 Aalborg University, Aalborg David Meredith
CINT & Reflex – The Future CINT’s Future Layout Reflex API Work In Progress: Use Reflex to store dictionary data Smaller memory footprint First step to.
Introduction to Objective-C and Xcode (Part 4) FA 175 Intro to Mobile App Development.
THE EYESWEB PLATFORM - GDE The EyesWeb XMI multimodal platform GDE 5 March 2015.
IBM Express Runtime Quick Start Workshop © 2007 IBM Corporation Deploying a Solution.
Mike Mulhearn & Drew Hobbs IMAGE ICON.  Paints icons from images  Images can be JPEG, JPG, GIF, PNG, BMP, WBMP  Images may also be created from a URL,
CHAPTER 9 File Storage Shared Preferences SQLite.
The Alfresco iOS SDK Gi Lee (Zia Consulting) Peter Schmidt (Alfresco)
KIT305/607 Mobile Application Development – Apple iOS Swift, Comparison of Swift and Objective-C, Swift Basics, Playgrounds, Persistent Storage Dr. Rainer.
Interstage BPM v11.2 1Copyright © 2010 FUJITSU LIMITED ADMINISTRATION.
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 12 Summer 2011.
Course Summary Xcode & iPhone Simulator
File System Interface CSSE 332 Operating Systems
Data Persistence Sisoft Technologies Pvt Ltd
Android Application Data Storage 1.
CHAPTER 5 JAVA FILE INPUT/OUTPUT
Operation System Program 4
EEC-492/693/793 iPhone Application Development
jQuery form submission
Lecture 16 - Interfaces Professor Adams.
UWP Application Data: Building a continuous application experience
EEC-492/693/793 iPhone Application Development
CSC 581: Mobile App Development
EEC-492/693/793 iPhone Application Development
Emerging Platform#3 Android & Programming an App
Presentation transcript:

Persistence CS 344 Mobile App Development Robert Muller

Options On-device or off-device; Property Lists, NSUserDefaults Archives SQLite (Thursday) Core Data (next Tuesday) – a higher-level & OO interface to SQLite iCloud CS 344 Mobile App Development - Muller

File System & Sandbox Why use a sandbox: – Security – Privacy – Ease of management App removal CS 344 Mobile App Development - Muller

File System & Sandbox Each app is assigned a set of directories – TheApp.app TheApp MainWIndow.xib Info.plist Image1.png,… – Documents <----- Persistent/Writeable Sandbox – Library Caches Preferences CS 344 Mobile App Development - Muller

Property Lists Commonly used abstraction for storing structured configuration data; Example: the Info.plist file found in every iOS app is a property list that stores configuration information about the app; You can use property lists yourself to store additional information, such as the state of your app when it quits. CS 344 Mobile App Development - Muller

Property Lists Utilize (restricted to) several Foundation datatypes: – dictionaries, – arrays, – strings, – dates, – binary data, – numerical and Boolean values; CS 344 Mobile App Development - Muller

Property Lists Stored as: – XML – Binary/Serialized Do not use property lists: – to store large values (e.g., large images); p-lists are loaded eagerly – Cannot store cyclic data structures, use archives instead CS 344 Mobile App Development - Muller

Writing and Reading App Data from Files NSUserDefaults + (NSUserDefaults *) standardUserDefaults; - (void) setObject:(id)val forKey:(NSString *)defaultName; - (id) objectForKey:(NSString *)defaultName; CS 344 Mobile App Development - Muller

Accessing File Resources Paths – strings of the form – Can refer to folder or file URLs: more general and now preferred – Can refer to folder or file – Can refer to a local or remote resource CS 344 Mobile App Development - Muller

NSPathUtilities.h directory is: NSHomeDirectory()); directory is: NSTemporaryDirectory()); NSArray *myArray = [[NSArray alloc] init]; myArray = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); path is: [myArray description]); User Name is: NSFullUserName()); CS 344 Mobile App Development - Muller

Writing and Reading App Data from Files -(BOOL) writeApplicationData:(NSData *)data toFile:(NSString *)fileName; -(NSData *)applicationDataFromFile:(NSString *) fileName; CS 344 Mobile App Development - Muller

NSData NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects. CS 344 Mobile App Development - Muller

-(BOOL) writeApplicationData:(NSData *)data toFile:(NSString *) fileName { NSFileManager *fm = [[NSFileManager alloc] init]; NSArray *urls = [fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; NSURL *docsDirectory = [urls objectAtIndex:0]; if (!docsDirectory) { directory not found."); return NO; } NSURL *myNewURL = [NSURL URLWithString:fileName relativeToURL:docsDirectory]; return ([data writeToURL:myNewURL atomically:YES]); }

CS 344 Mobile App Development - Muller -(BOOL) writeApplicationData:(NSData *)data toFile:(NSString *) fileName { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; if (!documentsDirectory) { directory not found."); return NO; } NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName]; return ([data writeToFile:appFile atomically:YES]); }

CS 344 Mobile App Development - Muller -(NSData *)applicationDataFromFile:(NSString *)fileName { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName]; NSData *myData = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease]; return myData; }

Serializing Property Lists -(BOOL)writeApplicationPlist:(id)plist toFile:(NSString*)fileName; Write out the property list in binary form. -(id) applicationPlistFromFile:(NSString *)fileName; Read the serialized property list from the specified file. CS 344 Mobile App Development - Muller

-(BOOL)writeApplicationPlist:(id)plist toFile:(NSString *) fileName { NSString *error; NSData *pData = [NSPropertyListSerialization dataFromPropertyList:plist format:NSPropertyListBinaryFormat_v1_0 errorDescription:&error]; if (!pData) { error); return NO; } return ([self writeApplicationData:pData toFile:fileName]); } CS 344 Mobile App Development - Muller

- (id) applicationPlistFromFile:(NSString *)fileName { NSData *retData; NSString *error; id retPlist; NSPropertyListFormat format; retData = [self applicationDataFromFile:fileName]; if (!retData) { file not returned."); return nil; } retPlist = [NSPropertyListSerialization propertyListFromData:retData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; if (!retPlist) not returned, error: error) return retPlist; } CS 344 Mobile App Development - Muller