Content Provider is an abstract data encapsulation and data access mechanism. For example, SQLite is a data source provided by Android devices and can be encapsulated into a content provider. To read and write data through content provider, you need to use Uri. Read Android learning notes (): Content
Provider first talk and Android contact information, Android learning notes (forty-eight): provide your own content provider and Android learning notes (forty-nine): Access data through content provider. Content
The important role of provider is to share data between applications. For data access within applications, Android provides multiple methods, including preferences, files, SQLite, and Internet access through HTTP Services.
Some Android built-in content providers can be viewed in the Android. provider software package, such as contact and mediastore. If they are not built-in, they must be implemented through the content provider interface.
Android Database
SQLite is a common data source for content providers. You can use Android and SQLite commands to process SQLite data. These commands are stored in/SDK/tools and/SDK/platform-tools. To facilitate the use of these commands, we set the script file myandroid. BAT in Windows to set environment variables. In Linux, you can set it through export Path = $ path: $ home.
Set SDK Path = D: \ developer \ adt-bundle-windows-x86 \ adt-bundle-windows-x86-20130522 \ SDK
Path = % PATH %; % sdkpath % \ tools; % sdkpath % \ platform-Tools
Android provides the adb command to operate the simulator or connected device. Adb, that is, Android Debug Bridge. Detailed commands can be read at http://developer.android.com/tools/help/adb.html.
We have learned how to useADB DevicesTo view the currently valid devices. If the device is not connected or the simulator is not enabledEmulator @AvdnameTo enable the simulator. avdname is the name of AVD.Android
List AVDCommand to view, of course, we can open through eclipse.
Run the following command to operate the connected device or simulator.
Adb shell
After entering, we can useLs/system/binView available commands. Data information is stored in/Data/DataDirectory, which is classified by the installation package. We can useLs
-R/data/*/databasesLook at the SQLite databases under those packages. For example, some built-in Android databases.
These*. DbThe file is an SQLite database. Android databases are usually created when they are accessed for the first time. To be close to the database:
Sqlite3/Data/<package name. For example, com. android. providers. contacts>/databases/<database file: contacts. db>
Below are some common SQLite commands:
Sqlite>. exit to exit sqlite
Sqlite>. tables: displays the tables List.
You can use the SQL language by adding a semicolon at the end.
From this ,. the content given by schema table_name is not intuitive. We can set *. copy the DB file and use a dedicated database tool to view it. For example, sqliteman can also be operated locally using the sqlite3 command. The command to drag out the file is as follows. If you do not enter the <local path>, it is the current directory.
Common SQL languages
Record some common SQL languages.
Select * From Table1;
Select count (*) from Table1;
Select col1, col2 from Table1;
Select distinct col1 from Table1;
Select count (col1) from (select distinct col1 from Table1 );
Select count (*), col1 from Table1 group by col1;
Select * From Table1 T1, Table2 T2 where t1.col1 = t2.col1;
Select * from Table T1 left Outer Join Table2 T2 on t1.col1 = t2.col1 where ....
Related links:
My android development articles