How to open Default Browser settings from my andro

2019-08-22 01:25发布

问题:

As per my requirement I have to clear default browser cache from my application. I want to open browser settings from my application, so that user can clear the cache. By using following code.

startActivityForResult(new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS), 0);

I'm able to open all manage applications. Is there any way to open browser settings directly?

Thanks

回答1:

Settings of an application is stored in Shared Preferances of the application and each application has different directories to store it by default. For your internet browser the settings are stored in "data/data/com.android.browser/shared-prefs/" direcory. There is a XML file named as "com.android.browser_preferences.xml" that has these settings. Access this file by shared prefs and make changes. Code.

String path = "data/data/com.android.browser/shared-prefs/";
String file = "com.android.browser_preferences.xml";
SharedPreferances setting = getSharedPreferances(path+file, MODE_PRIVATE, null);
SharedPreferances.editor edit = setting.edit();