Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsetting persistent system properties

Tags:

android

shell

adb

I can set a persistent system property on an Android phone (with appropriate permissions) using setprop <key> <value> command:

$ adb shell setprop persist.this.is.my.property testing

I can then confirm that the property was set:

$ adb shell getprop persist.this.is.my.property
testing

But I can't remove the key now that it is set (because of the persist at the start of the key it is there after the phone reboots). There is no unsetprop or rmprop or anything similar. Attempting to set the value to nil or null sets that to the value and leaving it empty prompts the help instructions.

Does anyone know how to unset a system property from the command line after it has been set?

like image 377
Stu Avatar asked May 08 '13 12:05

Stu


3 Answers

Prior to Android 9 Pie, the persistent property is stored as a file and can be removed.

rm /data/property/persist.this.is.my.property && reboot

Since Android 9 Pie, persistent properties are stored in a single file (commit 16fad42) and can only be unset.

setprop persist.this.is.my.property \"\" && reboot
like image 80
Stu Avatar answered Oct 16 '22 17:10

Stu


adb shell setprop persist.this.is.my.property \"\"
adb shell reboot

Changed the property value so it wouldn't be using it's previous value.
Empty quotes("") wouldnt work for me, I had to escape them(this is in bash).

like image 24
Pellet Avatar answered Oct 16 '22 18:10

Pellet


You can remove the property with adb shell setprop persist.this.is.my.property ""

like image 5
siavach Avatar answered Oct 16 '22 18:10

siavach