Search code examples
androidshelladb

Unsetting persistent system properties


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?


Solution

  • 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