Android中多用户的应用程序存储设置 [英] Storing settings in Android multi-user app

查看:684
本文介绍了Android中多用户的应用程序存储设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是存储在Android应用程序的用户设置是多用户的最佳方式?

What is the best way to store user settings in Android app which is multi-user?

现在我用

SharedPreferences sharedPref = PreferenceManager
 .getDefaultSharedPreferences(getActivity().getBaseContext());
String uid = sharedPref.getString("prompt-on-close", "N/A");

我觉得这不会为我工作,因为这将意味着,所有用户将共享相同的设置(如果用户退出,另一个标志中的值保持不变)。

I think this won't work for me as this would mean, all users would share the same settings (if user signs out and another signs in the values remains the same).

我发现了一个替代方案:

I discovered an alternative:

SharedPreferences sharedPref = getActivity().getSharedPreferences("user1", Context.MODE_PRIVATE);

我仍然不知道这是prefarable的解决方案,更重要的是,如果标准prefrences的对话框可以USET它。我认为它仅使用默认设置。

I'm still not sure if this is prefarable solution and more important, if standard Prefrences dialogs can uset it. I think it uses the default settings only.

推荐答案

您可以使用SQLlite为解决此问题,您可以创建只要你想,我通常使用此用户帐户的创建时间和更新数据的每个用户行方法时,我需要大量的preference的存储多用户应用程序
这里这个问题解决了疑问,在你的问题中约preferenceActivity <一个评论href=\"http://stackoverflow.com/questions/7500926/is-it-possible-to-use-$p$pferenceactivity-with-sqlite-instead-of-res-xml\">Is它可以使用preferenceActivity使用SQLite,而不是RES / XML?

You can use SQLlite for solving this issue,you can create rows for each users on user account creation time and update data whenever you want to,i usually use this method when i need to store a large amount of preference for multi-user applications and this question here solves the doubt in your question in comments about PreferenceActivity Is it Possible to Use PreferenceActivity with SQLite instead of res/xml?

这篇关于Android中多用户的应用程序存储设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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