# Using WRITE\_SECURE\_SETTINGS permission on non system apps

DevFeed: [Using WRITE\_SECURE\_SETTINGS permission on non system apps](<https://devfeed.tech/articles/using-write-secure-settings-permission-on-non-system-apps-21521.md>)

Original publisher: [Read original article](<http://lifepluslinux.blogspot.com/2015/10/using-writesecuresettings-permission-on.html>)

Author: Suresh Alse (noreply@blogger.com)

Published: 2015-10-25T08:44:00Z

Content type: tutorial

Language: en

Sources: [Life Plus Linux](<https://devfeed.tech/sources/life-plus-linux.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Wireless Debugging](<https://devfeed.tech/topics/wireless-debugging.md>), [App](<https://devfeed.tech/topics/app.md>), [APK](<https://devfeed.tech/topics/apk.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [adb](<https://devfeed.tech/tags/adb.md>), [android](<https://devfeed.tech/tags/android.md>), [apk](<https://devfeed.tech/tags/apk.md>), [app](<https://devfeed.tech/tags/app.md>), [code](<https://devfeed.tech/tags/code.md>), [permission](<https://devfeed.tech/tags/permission.md>), [root](<https://devfeed.tech/tags/root.md>)

## AI overview

A tutorial explains how an Android application can obtain the WRITE_SECURE_SETTINGS permission despite it being unavailable to non-system apps. It describes granting the permission with ADB or running the command from a root shell, noting that root access is required for the programmatic approach.

## Source excerpt

I happen to frequently use an app that doesn't work if USB Debugging - ADB (Android Debug Bridge) is enabled. It is very cumbersome to go to settings and enable or disable the setting every time I need to use the app. I checked if there are any widgets that could do this in a click and returned empty handed. So, I did what every developer would do - build it myself! In order to change the adb settings, I had to use WRITE_SECURE_SETTINGS permission. But there was one major problem! This permission is not available for non system apps!! The easiest solution to this was to move the apk to /system partition. Except that I didn't want to do this as I frequently keep flashing /system partition. Another solution was to use pm and grant permission to the app like this: adb pm grant <package name> android.permission.WRITE_SECURE_SETTINGS This was great! However I didn't want users who were gonna use the app to go through all this pain. I had to figure out a way to do the same programmatically. So I did the next best thing! To run the command after opening a root shell in the code. Here is how I did it. This requires root. But that's ok.