简体   繁体   English

是否可以在Xamarin中检索存储在Java中的Android共享首选项

[英]Is it possible to retrieve Android Shared Preferences in Xamarin that were stored in Java

I have an Android app that was previously written in Java and used SharedPreferences to store some details. 我有一个以前用Java编写并使用SharedPreferences存储一些细节的Android应用程序。 This app was left dormant for a number of years and wasn't updated with framework updates. 此应用已休眠了许多年,并且未通过框架更新进行更新。 So, when it came to updating it the decision was made to re-write it using Xamarin. 因此,在进行更新时,决定使用Xamarin重新编写它。 The app was written with the same package name and details so it could be built and rolled out as an update to the current app. 该应用程序使用相同的软件包名称和详细信息编写,因此可以作为当前应用程序的更新来构建和发布。

Now... What I'd like to do if possible, is retrieve the SharedPreferences stored to the phone in the java version of the app for use in the Xamarin version of the app. 现在...如果可能的话,我想做的是检索存储在手机的Java版本应用程序中的SharedPreferences,以便在该应用程序的Xamarin版本中使用。

I have the original code so I know what they were naming the Store and the variables. 我有原始代码,所以我知道他们在命名商店和变量。 I have the old app installed on a device and have stored some details by using the app. 我已将旧应用安装在设备上,并通过使用该应用存储了一些详细信息。

I have also added the necessary code to the new Xamarin app to get the shared preferences and debugged this on the same device. 我还向新的Xamarin应用程序中添加了必要的代码,以获取共享的首选项,并在同一设备上对其进行调试。 However, I'm not getting any values returned, just the default values defined. 但是,我没有得到任何返回的值,只是定义的默认值。

What I'd like to know is if anyone has been able to do this before or if what I'm trying is not possible since we're crossing languages now. 我想知道的是,是否有人以前能够做到这一点,或者由于我们现在正在跨语言交流,我正在尝试的事情是不可能的。

I assumed the latter however I wasn't going to give up without first trying and asking the community. 我以为是后者,但是如果不先尝试并询问社区,我不会放弃的。

Any thoughts or assistance would be greatly appreciated! 任何想法或协助将不胜感激!

Yes. 是。 The shared preference file is just XML. 共享的首选项文件只是XML。 There's nothing special about what language is used to read or write it. 关于使用哪种语言读取或编写语言没有什么特别的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM