How to set WRITE_SECURE_SETTINGS permission in android?

I am trying to enable accessibility service settings above 4.0, but Exception ie is displayed,

Called: java.lang.SecurityException: permission denied: android .permission.WRITE_SECURE_SETTINGS is required to write to secure settings

In the manifest, I declared this permission as follows.

<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> 

But in the manifest giving the compilation an Error, i.e. resolution is only system applications. Therefore, I do not understand how to solve this problem.

thanks in advance

Here is my sample code

 if (Settings.Secure.getString(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) { if (Settings.Secure.getString(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) { System.out.println("Putting the Value to Enable.."); Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0); } else { Settings.Secure.putInt(getContentResolver(), Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1); } } 
+6
source share
1 answer

WRITE_SECURE_SETTINGS is not available for applications. No application outside the system / firmware can get this edit.

Please check this answer

+5
source

Source: https://habr.com/ru/post/956546/