Crazy Android Handouts-Learn notes (vii)

Source: Internet
Author: User

8th Android data storage and IO

Java IO data storage can be ported to Android app Development, and the Android system also offers some specialized IO APIs.

The Android system has built-in SQLite database, SQLite is lightweight, no background process, the entire database corresponding to a file, so it is very convenient to migrate between different devices. Android provides a number of convenient APIs for accessing SQLite.

8.1 Using Sharedpreferences

Applies to saving data in a simple format.

8.1.1 Sharedpreferences and Editor

The data that Sharedprefernces saves is primarily data that resembles the configuration information format, so the data it holds is mostly key-value.

The Sharedpreferences interface is primarily responsible for reading the program's preferences data without providing the ability to write data.

Sharedpreferences calls the edit () method to get the editor object it corresponds to, which is provided by the Editor object, and after editing is completed, a commit () is called.

Sharedpreferences is an interface that needs to invoke the Getsharedpreferences () method provided by the context to get its instance.

Storage location and format of 8.1.2 Sharedpreferences

( source \08\8.1\sharedpreferencestest)

8.1.3 Read and write sharedpreferences for other applications

The premise is that other applications specify the appropriate access rights.

The key is to get the context,context of other applications that represent the global information interface for Android apps.

The Android system takes the package name of the application as its unique identity.

8.2 File Storage

The I/O stream provided by Java

8.2.1 Openfileoutput and Openfileinput (method provided by the context)

8.2.2 Read and write files on SD card

( source \08\8.2\sdfileexplorer)

8.3 SQLite Database

SQLite supports most of the SQL92 syntax and runs developers using SQL statements to manipulate data, but the SQLite database is just a file.

8.3.1 SQLite Introduction

8.3.2 Creating databases and tables

8.3.3 using SQL statements to manipulate SQLite

8.3.4 using the Sqlite3 tool

8.3.5 uses a specific method to manipulate the SQLite database, which is the method provided by the Android Sqlitedatabase.

The method for controlling transactions in the 8.3.6 transaction sqlitedatabase: BeginTransaction (), Endtransaction (), and intransaction () are used to determine whether they are in a transaction.

The 8.3.7 Sqliteopenhelper class is a tool class for managing databases provided by Android.

The Sqlitedatabase method is seldom used in actual projects to open the data, usually inheriting the sqliteopenhelper development subclass, and through the subclass's

The Getreadabledatabase (), Getwritabledatabase () method opens the database.

8.4 Gestures (Gesture)

The 8.4.1 gesture detects the Gesturedetector class, which is required to pass in a Gesturedetector.ongesturelistener listener instance, which processes the required events.

8.4.2 increasing gestures

8.4.3 Identifying users ' gestures

8.5 automatic reading (TTS)

Android provides automatic read-aloud support

The 9th chapter uses ContentProvider to realize data sharing

ContentProvider is the standard API for data exchange between different applications. Exposing your data with ContentProvider, other applications can manipulate the exposed data through contentresolve.

9.1 Data Sharing Standard: ContentProvider introduction

9.1.1 ContentProvider

9.1.2 URI Introduction

9.1.3 using Contentresolver to manipulate data

9.2 Development ContentProvider

The relationship between 9.2.1 ContentProvider and Contentresolver

The URI is the identity of the ContentProvider and Contentresolver for data exchange.

9.2.2 Development ContentProvider

9.2.3 Configuration ContentProvider

9.2.4 calling methods using Contentresolver

9.2.5 instructions for creating a ContentProvider

9.3 ContentProvider of the operating system

The Android system itself provides a lot of contentprovider

9.3.1 managing contacts with ContentProvider

9.3.2 using ContentProvider to manage multimedia content

9.4 Monitoring of ContentProvider data changes

9.4.1 Contentobserver profile is used to monitor changes in ContentProvider data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.