安卓:检索共享的其它应用preferences [英] Android: Retrieving shared preferences of other application

查看:128
本文介绍了安卓:检索共享的其它应用preferences的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序的设置,从我所检索的其他应用程序preferences,但我没有在这些关键的细节,我怎么能检索所有在preference可用键和值?

I have a settings application from which i have to retrieve other applications preferences, but i don't have the details of keys in them, how can i retrieve all the available keys and values in that preference?

谢谢, Swathi

Thanks, Swathi

推荐答案

假设preference的WORLD_READABLE,这可能工作:

Assuming the preference are WORLD_READABLE, this might work:

final ArrayList<HashMap<String,String>> LIST = new ArrayList<HashMap<String,String>>();
Context myContext = createPackageContext("com.example", 
Context.MODE_WORLD_WRITEABLE); // where com.example is the owning  app containing the preferences
  SharedPreferences testPrefs = myContext.getSharedPreferences 
("test_prefs", Context.MODE_WORLD_READABLE); 


Map<String, ?> items = testPrefs .getAll();
for(String s : items.keySet()){
    //do somthing like String value=  items.get(s).toString());
    }

这篇关于安卓:检索共享的其它应用preferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆