Android數據庫sqlite3及settings命令設置

Android數據庫sqlite3及settings命令設置

1. Android數據庫sqlite3命令設置

1.1. 進入板子上的數據庫路徑

shell@pineapple: cd /data/data/com.android.providers.settings/databases
shell@pineapple:~ # ls
settings.db
settings.db-journal
shell@pineapple:~ #

1.2. 進入數據庫操作

shell@pineapple:~ # sqlite3 settings.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

1.3. 查看當前有哪些數據表

sqlite> .table
android_metadata   bookmarks          secure           
bluetooth_devices  global             system           

1.4. 查看當前global數據表中有哪些內容

sqlite> select * from global;
1|airplane_mode_on|0
2|airplane_mode_radios|cell,bluetooth,wifi,nfc,wimax
3|airplane_mode_toggleable_radios|bluetooth,wifi,nfc
4|assisted_gps_enabled|0
5|auto_time|1
6|auto_time_zone|1
7|stay_on_while_plugged_in|0
8|wifi_sleep_policy|2
9|mode_ringer|2
10|package_verifier_enable|1
12|wifi_networks_available_notification_on|1
13|bluetooth_on|0
14|cdma_cell_broadcast_sms|1
15|data_roaming|0
17|mobile_data|1
18|netstats_enabled|1
19|install_non_market_apps|0
20|usb_mass_storage_enabled|1
21|wifi_max_dhcp_retry_count|9
22|wifi_display_on|0
23|lock_sound|/system/media/audio/ui/Lock.ogg
24|unlock_sound|/system/media/audio/ui/Unlock.ogg
25|power_sounds_enabled|1
26|low_battery_sound|/system/media/audio/ui/LowBattery.ogg
27|dock_sounds_enabled|0
28|desk_dock_sound|/system/media/audio/ui/Dock.ogg
29|desk_undock_sound|/system/media/audio/ui/Undock.ogg
30|car_dock_sound|/system/media/audio/ui/Dock.ogg
31|car_undock_sound|/system/media/audio/ui/Undock.ogg
32|wireless_charging_started_sound|/system/media/audio/ui/WirelessChargingStarted.ogg
33|dock_audio_media_enabled|1
34|set_install_location|0
35|default_install_location|0
36|emergency_tone|0
37|call_auto_retry|0
38|preferred_network_mode|0
39|subscription_mode|1
40|low_battery_sound_timeout|0
41|wifi_ap_on|4
42|network_preference|9
43|wifi_watchdog_on|1
44|adb_enabled|1
45|device_provisioned|1
46|audio_safe_volume_state|3
47|wifi_on|1
sqlite> 

1.5. 修改數據表global中數據值

## 修改global表中wifi_on的值,where_id表示在數據表中排行第幾個,value爲修改值
sqlite> update global set value=2 where _id=14;
sqlite> select * from global;
14|wifi_on|2    ## 說明已經修改過來了

1.6. 在數據表中插入一個新的數據

## 由上面1.4已知道數據表global中共有47個數據,那接下來新增加的數據說是做爲第48個
## 新添加connectivity_change_delay的數據,設定值爲0
sqlite> insert into global values(48,'connectivity_change_delay',0);
sqlite> select * from global;
48|connectivity_change_delay'|0    
## 以上可以查看到,說明已經添加進來了,接下來重啓系統就可以生效了

2. Android數據庫settings命令設置

可以直接通過settings命令進行操作

2.1 settings的使用說明

root $ settings                                                     
Settings provider (settings) commands:
  help
      Print this help text.
  get [--user <USER_ID> | current] NAMESPACE KEY
      Retrieve the current value of KEY.
  put [--user <USER_ID> | current] NAMESPACE KEY VALUE [TAG] [default]
      Change the contents of KEY to VALUE.
      TAG to associate with the setting.
      {default} to set as the default, case-insensitive only for
      global/secure namespace
  delete NAMESPACE KEY
      Delete the entry for KEY.
  reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}
      Reset the global/secure table for a package with mode.
      RESET_MODE is one of {untrusted_defaults, untrusted_clear, 
      trusted_defaults}, case-insensitive
  list NAMESPACE
      Print all defined keys.
      NAMESPACE is one of {system, secure, global}, case-insensitive

2.2. 查看當前global數據表中有哪些內容

## 舊的版本android4.4及以下不可用,新的版本5.0以上可以用
## 從2.1也可以知道,可以直接查看system或者secure的內容
root $ settings list global                                         
adb_enabled=1
add_users_when_locked=0
airplane_mode_on=0
airplane_mode_radios=cell,bluetooth,wifi,nfc,wimax
airplane_mode_toggleable_radios=bluetooth,wifi,nfc
assisted_gps_enabled=0
audio_safe_volume_state=3
auto_time=1
auto_time_zone=1
bluetooth_disabled_profiles=0
bluetooth_on=0
boot_count=10
call_auto_retry=0
captive_portal_mode=0
car_dock_sound=/system/media/audio/ui/Dock.ogg
car_undock_sound=/system/media/audio/ui/Undock.ogg
cdma_cell_broadcast_sms=1
data_roaming=0
database_creation_buildid=OPR5.170623.014
default_install_location=0
desk_dock_sound=/system/media/audio/ui/Dock.ogg
desk_undock_sound=/system/media/audio/ui/Undock.ogg
device_name=sugarcane
device_provisioned=1
dock_audio_media_enabled=1
dock_sounds_enabled=0
dock_sounds_enabled_when_accessbility=0
emergency_affordance_needed=0
emergency_tone=0
ethernet_on=3
heads_up_notifications_enabled=1
lock_sound=/system/media/audio/ui/Lock.ogg
low_battery_sound=/system/media/audio/ui/LowBattery.ogg
low_battery_sound_timeout=0
mobile_data=1
mode_ringer=2
netstats_enabled=1
network_recommendations_enabled=0
network_recommendations_package=
package_verifier_enable=1
power_sounds_enabled=1
preferred_network_mode=0
set_install_location=0
stay_on_while_plugged_in=0
subscription_mode=0
theater_mode_on=0
trusted_sound=/system/media/audio/ui/Trusted.ogg
unlock_sound=/system/media/audio/ui/Unlock.ogg
usb_mass_storage_enabled=1
volte_vt_enabled=1
webview_provider=com.android.webview
wifi_ap_on=4
wifi_display_on=0
wifi_max_dhcp_retry_count=0
wifi_networks_available_notification_on=1
wifi_on=1
wifi_scan_always_enabled=0
wifi_sleep_policy=2
wifi_verbose_logging_enabled=1
wifi_wakeup_available=0
wifi_wakeup_enabled=1
wireless_charging_started_sound=/system/media/audio/ui/WirelessChargingStarted.ogg
zen_mode=0
zen_mode_config_etag=-350912202
root $

2.3. 查看數據表global中數據的值

root $ settings get global wifi_on          
1
root $ 

2.4. 修改數據表global中數據的值

root $ settings set global wifi_on    0
root $ settings get global wifi_on          
0
root $ 

2.5. 在數據表中插入一個新的數據

root $ settings set global wifi_on_status  1
root $ settings get global wifi_on_status     
1
root $ 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章