How to grant system permission

2020-02-14 20:02发布

问题:

I am just trying to clear the app data and getting below error

java.lang.SecurityException: Neither user 10028 nor current process has 
android.permission.CLEAR_APP_USER_DATA.

I am using some hidden apis

How can i grant this permission

Thanks in Advance.

回答1:

You will not get that permission in a normal device unless you are developing system app. Refer to this article. You can add that to your manifest, adding this permission will not cause any compile error or warning. But it will simply not work in run time.

By the way, if you really need to clear the data of your application, why don't you one by one clear the files/preferences you are generating from your application for purpose of "data"?



回答2:

You need to set a uses-permission in a AndroidManifest.xml file The permission will look like this:

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

And will be placed within the manifest element of the xml file.

You can set it using manifest designer in eclipse by opening the AndroidManifest.xml file, then clicking on the Permissions tab (at the bottom). Then click Add and select "Uses Permission". You will find the permission you are looking for in the list.

You will not be able to clear the user data from the app without this permission.

See more information on permissions here and here



回答3:

go to manifest-> permissions tab-> add permission-> select uses-permissions-> select specific permission-> save.