1

我正在尝试使用此代码更改 android 默认浏览器的私有共享首选项

Context browserContext = null;
    try {
        browserContext = createPackageContext("com.android.browser", Context.MODE_PRIVATE);
    } catch (NameNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    SharedPreferences sp = browserContext.getSharedPreferences("com.android.browser_preferences", Context.MODE_PRIVATE);                 
    SharedPreferences.Editor edidor = sp.edit();
    edidor.putString("homepage", "http://www.yahoo.com");
    edidor.commit();

日志猫如下

 08-26 12:44:20.106: W/ApplicationContext(6673): Attempt to read preferences file       /data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml without    permission
 08-26 12:44:20.116: E/ApplicationContext(6673): Couldn't rename file /data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml to backup file /data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml.bak

但这会导致访问被拒绝错误。

如何更改浏览器的主页?可以使用NDK代码完成吗?

4

0 回答 0