[First written by Steve Guo, please keep the mark if forwarding.]

Androidsaved settings in a database filewhich is/data/data/com.android.providers.settings/databases/settings.db. For some settings, Android does not support set them on the GUI. So we need find another way to set it. Here it is. I will use set "device_provisioned" as an example.

Android use sqlite3 as the database. So we can use sqlite3 to manage the database file.

adb shell

sqlite3 /data/data/com.android.providers.settings/databases/settings.db

注意:sqlite3有2个。一个是电脑上的,它位于android-sdk-windows\tools\sqlite3.exe,它用于电脑上;

还有一个位于android系统上(手机上),它才是用于Android系统的,对于后者你需要通过adb shell进入shell。

前者是window系统,后者是Linux系统,他们文件系统的表示方法不一样。

The above command will open the settings database. Then you will enter into sqlite3 command line.

First we can check how many tables existed in the database. Here lists the result.

sqlite> .tables
android_metadata bookmarks gservices
bluetooth_devices favorites system

The settings we try to set lies in "system" table, so then we list all items in the table to view the current table information.
sqlite>.dump system
BEGIN TRANSACTION;
CREATE TABLE system (_id INTEGER PRIMARY KEY AUTOINCREMENT,nameTEXT UNIQUE ON CONFLICT REPLACE,valueTEXT);
INSERT INTO "system" VALUES(3,'volume_system','5');
INSERT INTO "system" VALUES(4,'volume_voice','4');
INSERT INTO "system" VALUES(5,'volume_alarm','6');
INSERT INTO "system" VALUES(6,'mode_ringer','2');
INSERT INTO "system" VALUES(7,'vibrate_on','4');
INSERT INTO "system" VALUES(8,'mode_ringer_streams_affected','6');
INSERT INTO "system" VALUES(9,'mute_streams_affected','14');
INSERT INTO "system" VALUES(10,'dim_screen','1');
INSERT INTO "system" VALUES(11,'stay_on_while_plugged_in','0');
INSERT INTO "system" VALUES(12,'screen_off_timeout','60000');
INSERT INTO "system" VALUES(13,'airplane_mode_radios','cell,bluetooth,wifi');
INSERT INTO "system" VALUES(14,'airplane_mode_on','0');
INSERT INTO "system" VALUES(15,'bluetooth_on','0');
INSERT INTO "system" VALUES(16,'usb_mass_storage_enabled','1');
INSERT INTO "system" VALUES(17,'wifi_on','0');
INSERT INTO "system" VALUES(18,'wifi_networks_available_notification_on','1');
INSERT INTO "system" VALUES(19,'network_preference','1');
INSERT INTO "system" VALUES(20,'auto_time','1');
INSERT INTO "system" VALUES(21,'screen_brightness','102');
INSERT INTO "system" VALUES(23,'window_animation_scale','1');
INSERT INTO "system" VALUES(24,'transition_animation_scale','0');
INSERT INTO "system" VALUES(26,'data_roaming','0');
INSERT INTO "system" VALUES(27,'date_format','MM-dd-yyyy');
INSERT INTO "system" VALUES(30,'device_provisioned','0');
INSERT INTO "system" VALUES(31,'location_providers_allowed','gps');
INSERT INTO "system" VALUES(32,'install_non_market_apps','1');
INSERT INTO "system" VALUES(119,'ringtone','content://media/external/audio/media/11');
INSERT INTO "system" VALUES(243,'volume_music','15');
INSERT INTO "system" VALUES(244,'volume_music_last_audible','15');
INSERT INTO "system" VALUES(266,'volume_ring','7');
INSERT INTO "system" VALUES(267,'volume_ring_last_audible','7');
INSERT INTO "system" VALUES(274,'font_scale','1.0');
INSERT INTO "system" VALUES(275,'adb_enabled','0');
INSERT INTO "system" VALUES(276,'next_alarm_formatted','');
CREATE INDEX systemIndex1 ON system (name);
COMMIT;

如果我们只想看system表的内容,直接用SQL语句也就可以了 比如:

select * from system;

注意1sqlite3支持两种命令,一种是SQL命令,一种是非SQL命令,非SQL命令以"."作为前缀,比如".tables"命令。

所以所有不以"."为前缀的语句,都将做SQL进行解释,当时对于SQL语句你需要在末尾加上分号";"以表示SQL语句输入完成,

这时你输入的命令才开始才按照SQL语言进行执行。

注意2sqlite3的命令可以通过".help"语言来查看。

Pay attention to the first line about table information. The text marked with red will be used when writting SQL statements. Assume we want to set "device_provisioned" to 1, we can simply typethe following statementin the sqlite3 console.

sqlite>UPDATE "system" SET value='1' WHERE name='device_provisioned';

你可以输入 ".dump system"或select * from system;来检查修改后的值.


更多相关文章

  1. 【android-tips】android程序执行adb shell命令(实例源码)
  2. android执行Linux命令
  3. android 使用linux命令截屏
  4. android常用语句
  5. Android(安卓)cts测试命令
  6. Android(安卓)以太网调用流程
  7. Android实现远程控制PC(Android[客户端]+Qt[服务器端])
  8. 立即停止Android(安卓)Studio 编译
  9. Android实现远程控制PC(Android[客户端]+Qt[服务器端])

随机推荐

  1. Android(安卓)使用Lottie的三个小技巧
  2. android 设置应用退出后不在运行列表中显
  3. Ubuntu下android源码下载与编译
  4. Android的init过程(二):初始化语言(init.rc)解
  5. Android应用实例之----天气预报程序
  6. Android发送邮件到指定邮箱(可带附件)
  7. Android(安卓)Market 账号注册和应用发布
  8. android中做网络请求的几种方式
  9. android 登陆、提交数据或加载数据时提示
  10. Testing和Instrumentation