I am trying to use the following code to set my page as the browser homepage, but it is not working:
Context browserContext = createPackageContext("com.android.browser", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences sp = browserContext.getSharedPreferences("com.android.browser_preferences",Context.MODE_PRIVATE);
SharedPreferences.Editor edidor = sp.edit();
edidor.putString("homepage", "http://www.mypage.com");
edidor.commit();
I am getting this warning:
///data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml without permission
.
As both application process ids are different, I cannot access the SharedPreferences of Browser application.
So:
- How do I achieve this task?
- Are there other approaches to try, such as a javascript or web page loading?
- Can I open
setHomepage
dialog of default browser programmatically?