 data/data-storage.html#pref data/data-storage.html#pref 

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

The Web Warrior Guide to Web Design Technologies
Tracking & Login Data persistence User tracking.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Chapter 12 Working With Access 2000 on the Internet.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Tutorial 11: Connecting to External Data
SQLite BY Jordan Smith Brian Wetzel Chris Hull William Anderson.
CS378 - Mobile Computing Persistence - SQLite. Databases RDBMS – relational data base management system Relational databases introduced by E. F. Codd.
Data Persistence in Android
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
Data Storage: Part 1 (Preferences)
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Your Interactive Guide to the Digital World Discovering Computers 2012.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
Content providers Accessing shared data in a uniform way 1Content providers.
Cosc 5/4730 Android Content Providers and Intents.
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.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Recitation.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Chapter 8 Cookies And Security JavaScript, Third Edition.
INDIANAUNIVERSITYINDIANAUNIVERSITY OneStart page types  Tab – pages across the top, immutable  Section – pages down the left  Subsection – pages under.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Nilesh Singh Local Data Storage option Android provides several options for you to save persistent application data. - Shared preferences - Creation.
Data persistence How to save data using SharedPreferences, Files, and SQLite database 1Data persistence.
9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Data Persistence Nasrullah Niazi. Share Preferences The SharedPreferences class provides a general framework that allows you to save and retrieve persistent.
Object Oriented Software Development 10. Persistent Storage.
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.
SQLite DB Storing Data in Android RAVI GAURAV PANDEY 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Proposal for an Open Source Flash Failure Analysis Platform (FLAP) By Michael Tomer, Cory Shirts, SzeHsiang Harper, Jake Johns
Server-Side Solutions Steve Perry
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
CHAPTER 9 File Storage Shared Preferences SQLite.
Exploring Networked Data and Data Stores Lesson 3.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
Mobile Application Development Data Storage. Android provides several options for you to save persistent application data. The solution you choose depends.
Introduction to Database Programming with Python Gary Stewart
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
Editing a Twitter search. Viewing search results in a browser.
Data Persistence Chapter 9. Objectives Learn about data storage methods Understand use of Shared Preferences Understand file-based storage and the differences.
Android Application Data Storage 1.
SQLite in Android Landon Cox March 2, 2017.
Mobile Software Development for Android - I397
Introduction to Classes and Objects
Mobile Applications (Android Programming)
Android Application SQLite 1.
Android Database using SQLite
Mobile Application Development Chapter 5 [Persistent Data in Android]
Listing 9.1 ShowLocalConnection.aspx
Principles of report writing
ISC440: Web Programming 2 Server-side Scripting PHP 3
Developing a Model-View-Controller Component for Joomla Part 3
Chapter 10 ADO.
Mobile Programming Dr. Mohsin Ali Memon.
Preference Activity class
Presentation transcript:

 data/data-storage.html#pref data/data-storage.html#pref  ples/63.html ples/63.html  Hello Android, chapter 9

 Shared Preferences Shared Preferences ◦ Store private primitive data in key-value pairs.  Internal Storage Internal Storage ◦ Store private data on the device memory.  External Storage External Storage ◦ Store public data on the shared external storage.  SQLite Databases SQLite Databases ◦ Store structured data in a private database.  Network Connection Network Connection ◦ Store data on the web with your own network server

Store private primitive data in key-value pairs

 How to save and retrieve data?  Using SharePrference class ◦ persistent key-value pairs ◦ only primitive data types.  booleans, floats, ints, longs, and strings.  This data will persist across user sessions ◦ even if your application is killed

 getSharedPreferences() getSharedPreferences() ◦ Use this if you need multiple preferences files identified by name, which you specify with the first parameter.  getPreferences() getPreferences() ◦ Use this if you need only one preferences file for your Activity. Because this will be the only preferences file for your Activity, you don't supply a name

 Write ◦ Call edit() to get a SharedPreferences.Editor.edit()SharedPreferences.Editor ◦ Add values with methods such as putBoolean() and putString().putBoolean() putString() ◦ Commit the new values with commit()commit()  Read ◦ use SharedPreferences methods such as getBoolean() and getString().SharedPreferences getBoolean()getString()

Store private data on the device memory

 You can save files directly on the device's internal storage.  By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user).  When the user uninstalls your application, these files are removed.

 Call openFileOutput() with the name of the file and the operating mode. This returns a FileOutputStream.openFileOutput()FileOutputStream  Write to the file with write().write()  Close the stream with close().close()

 Call openFileInput() and pass it the name of the file to read. This returns a FileInputStream.openFileInput()FileInputStream  Read bytes from the file with read().read()  Then close the stream with close().close()

 XML resources can mean resources in general that are defined in XML, ◦ layout files, styles, arrays, res/xml XML files.  In this section we will be dealing with res/xml XML files.

SQLite Databases

 A tiny yet powerful database engine created by Dr. Richard Hipp in  It is arguably the most widely deployed SQL database engine in the world.  Besides Android, SQLite can be found in the Apple iPhone, Symbian phones, Mozilla Firefox, Skype, PHP, Adobe AIR, Mac OS X, Solaris, and many other places.

 It’s free. ◦ The authors have placed it in the public domain and don’t charge for its use.  It’s small. ◦ The current version is about 150KB, well within the memory budget of an Android phone.  It requires no setup or administration. ◦ There is no server, no config file, and no need for a database administrator.

 Android stores the file ◦ /data/data/packagename/databases  You can take that file, move it around, and even copy it to another system ◦ for example, from your phone to your workstation), and it will work fine.  You can use the adb command or the File Explorer view in Eclipse to view, move, or delete it. ◦ Window > Show View > Other... > Android > File Explorer)

Nothing here yet

 Goal ◦ Save time stamps and string to a table ◦ Display it

 Constants describing the database ◦ Constants interface  represent the database ◦ Using SQLiteOpenHelper  Driver ◦ Main program

manages database creation and versions. All you need to do is provide a constructor and override two methods. DATABASE_VERSION is just a number we make up. If this were a real program, you would increase the version number whenever you had to make significant changes to the database design (for example, to add a new column).

close the database inside the finally block. So even if an error occurs in the middle, the database will still be closed. Every time you run this program, you’ll get a new event. Running a Query

 Allows you to connect your model (data) to your view with just a few lines of code.  To demonstrate data binding, we’ll modify the Events example to use a ListView that is bound to the result of a database query.

putting the ID, time, and title on one line with colons in between the fields. added a little padding and formatting to make it look nice.

need to change the layout for the activity itself in layout/main.xml