查看一个Android应用程序的共享preferences?应用程序、Android、preferences

由网友(毛绒暖暖)分享简介:在我的工作我的应用程序在Eclipse中,有没有办法看到我为应用程序的共享preferences而这是调试在模拟器中的变化?在此先感谢When I am working on my app in eclipse, is there a way to see the changes I make to the shar...

在我的工作我的应用程序在Eclipse中,有没有办法看到我为应用程序的共享preferences而这是调试在模拟器中的变化?在此先感谢

When I am working on my app in eclipse, is there a way to see the changes I make to the shared preferences of the app while it is debugging in the emulator? Thanks in advance

推荐答案

运行项目在仿真器,然后从Eclipse的菜单中选择Windows的>打开透视图 - > DDMS。 从标签装置,选择模拟器的名字,然后进入资源管理器,展开数据 - >数据 - > yourpackagename,你应该看到的份额参考XML文件(只能在模拟器或一个植根设备的)。最后,导出该文件到Windows。 参见http://developer.android.com/tools/debugging/ddms.html 的更新: 另一种方法,你可以听的共享preference变化:

Run project in emulator, then from Eclipse choose menu Windows-> open perspective ->DDMS. From tab device, choose emulator name, then go to file explorer,expand data->data->yourpackagename, you should see share reference xml file (only work on the emulator or a rooted device). Finally, export this file to windows. See http://developer.android.com/tools/debugging/ddms.html Update: Another way, you can listen shared preference change:

SharedPreferences.OnSharedPreferenceChangeListener prefListener = 
new SharedPreferences.OnSharedPreferenceChangeListener() {
  public void onSharedPreferenceChanged(SharedPreferences prefs,String key) {
if (key.equals("YourKey")) 
     {
          //Get this
     } 
 }

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);          
preferences.registerOnSharedPreferenceChangeListener(prefListener);

请参阅Shared$p$pferences.onShared$p$pferenceChangeListener没有所谓的一贯

阅读全文

相关推荐

最新文章