Android中多用户的应用程序存储设置

编程入门 行业动态 更新时间:2024-10-13 12:23:23
本文介绍了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 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中多用户的应用程序存储设置

本文发布于:2023-10-24 21:06:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1525003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多用户   应用程序   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!