Android Content Command

Source: Internet
Author: User
Tags sqlite

In order to facilitate debugging, simply introduced under the Android serial port How to modify the value of the database.

The first way to use the Sqlite3 command:
1, first enter the sqlite3 command mode:
**shell@ubuntu:/database # Sqlite3 User_setting.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter '. Help ' for instructions
Enter SQL statements terminated with a ";"
sqlite>**
A few simple notes:
You can enter. Help View command Instructions
Frequently used commands to see which data tables are:. Tables; Exit sqlite3 Command mode:. Quit
If you want to remove characters, you need to use CTRL + Backspace.
2, view the value of a table:
View all columns: SELECT * from tbl_systemsetting; (Note to have a semicolon; )
Output results:
*sqlite> Select from Tbl_systemsetting;
0|0|0|0|0|2|50|0|0|0|26|0|0|0|4|0|1|0|0|0|3|5000|0|1|0|8| 0|0|0|2|0|0|1|0|0|1|4|0|0|0|0|0|0|0|3|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0|65535|0|1|4|0|1|1|1|1|1|1|0| 100|50|1|1**
To view the values of a single column, the name of the specific column needs to be checked for the corresponding SQL file:select Eninputsourcetype from tbl_systemsetting;
Output results:
sqlite> Select Eninputsourcetype from tbl_systemsetting;
2
3, update a field value:update tbl_systemsetting set eninputsourcetype=1;
Output results:
**sqlite> update tbl_systemsetting set eninputsourcetype=1;
Sqlite> select Eninputsourcetype from tbl_systemsetting;
1**

The second method uses the content command, which is more "beautiful"
The shell input content, will output the usage information
*USAGE:ADB shell content [subcommand] [options]
USAGE:ADB Shell content Insert–uri [–user]–bind [–bind ...]
A content provider URI.
Binds a typed value to a column and is formatted:
:: Where:
Specifies data type such as:
B-boolean, S-string, I-integer, L-long, F-float, d-double
Note:omit the value for passing a empty string, e.g Column:s:
Example:
Add "new_setting" secure setting with Value "New_value".
adb shell content Insert–uri content://settings/secure–bind Name:s:new_setting–bind value:s:new_value
USAGE:ADB Shell content Update–uri [–user] [–where]
is a SQL style WHERE clause in quotes (for you have to escape single Quotes-see example below).
Example:
Change "new_setting" secure setting to "Newer_value".
adb shell content Update–uri content://settings/secure–bind value:s:newer_value–where "name= ' new_setting '"
USAGE:ADB Shell content Delete–uri [–user]–bind [–bind ...] [–where]
Example:
Remove "new_setting" secure setting.
adb shell content Delete–uri content://settings/secure–where "name= ' new_setting '"
USAGE:ADB Shell content Query–uri [–user] [–projection] [–where] [–sort]
is a list of colon separated column names and is formatted:
[:...]
is the order of which rows in the result should be sorted.
Example:
Select ' name ' and ' value ' columns from secure settings where ' name ' is equal to ' new_setting ' and sort the ' result by name in ascending order.
adb shell content Query–uri content://settings/secure–projection name:value–where "name= ' new_setting '" –sort "name ASC"
USAGE:ADB Shell content Call–uri–method [–arg]
[–extra ...]
is the name of a provider-defined method
is a optional string argument
is like–bind above, typed data of the form: {b,s,i,l,f,d}:
1, inquiry
Command line Input: Content Query–uri content://abcd.tv.usersetting/systemsetting
Output results:
row:0 _id=0, Fruninstallationguide=0, Fnochannel=0, bdisablesiautoupdate=0, Bdisabledynamicrescan=0, Eninputsourcetype=1, Country=50, Encableoperators=0, ensatelliteplatform=0, U16networkid=0, Language=26, En3DARC=0, Enspdifmode=0, Fsoftwareupdate=0, u8oadtime=4, Foadscanafterwakeup=0, fautovolume=1, fDcPowerOFFMode=0, DtvRoute=0, Scartoutrgb=0, U8transparency=3, u32menutimeout=5000, audioonly=0, Benablewdt=1, u8favoriteregion=0, U8Bandwidth=8, U8timeshiftsizetype=0, Foadscan=0, Benablepvrrecordall=0, u8colorrangemode=2, U8hdmiaudiosource=0, Benablealwaystimeshift=0, Esuper=1, Buartbus=0, m_autozoom=0, Boverscan=1, m_u8brazilvideostandardtype=4, m_ U8softwareupdatemode=0, Osd_active_time=0, m_messageboxexist=0, u16lastoadversion=0, BEnableAutoChannelUpdate=0, U32pvrsettingid=0, Enforcedinputsourcetype=0, enlocaldimm=3, batvchswitchfreeze=1, bSourceDetectEnable=1, Bautosourceswitch=0, u32msrvtimercounter=0, standbynooperation=0, standbynosignal=0, ScreenSaveMode=0, Bautomhlswitch=0, BVIewerprompt=0, U8opmode=0, u32cicamidentifier=0, benablehbbtv=0, bwolenable=0, u32strpowermode=0, BEnableACR=0, Bsourcepreview=0, Bmonitoritc=0, bxvycconoff=0, Benablestorecookies=1, Bservicelistneedrearrange=0, Bcioccupiedtuner=0, u16cipincode=65535, u16hdmidedidversion=0, enmemoryinputsource=1, TTX_Language=4, Bbluescreenmode=0, Bmainautodetecthdrlevel=1, bsubautodetecthdrlevel=1, u8mainhdrlevel=1, U8SubHdrLevel=1, Bmainhdron=1, Bsubhdron=1, Bdcrstatus=0, bdcrbacklightmax=100, bdcrbacklightrange=50, BDCRBacklightStep=1, Bdcrsteptime=1*

Query a column, that is, the value of a field:content Query–uri content://abcd.tv.usersetting/systemsetting–projection eninputsourcetype
Output results:
row:0 eninputsourcetype=1

2. Update a field data value
For example, I want to update Eninputsourcetype 2, its data type is int, then the command is as follows:
content Update–uri Content://abcd.tv.usersetting/systemsetting–bind eninputsourcetype:i:2 // Separating the first with a colon is the field name, the second is the field type, and the third is the final value to write.
More commonly used should be query and delete, specifically to understand how the code to achieve, you can go to see android/frameworks/base/cmds/content/src/com/android/commands/content/ Content.java

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.