您是否应该使用AccountManager存储Android应用的用户名和密码? [英] Should you use AccountManager for storing Usernames and Passwords for an Android app?

查看:1449
本文介绍了您是否应该使用AccountManager存储Android应用的用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否应该实现 AccountManager 来保存用户凭据,例如用户名,电子邮件,密码等。我找不到合理的理由来使用它我自己。

I would like to know if one should implement AccountManager to save user credentials such as username, email, passwords etc. I can't find a good reason to use it myself.

我不希望其他应用程序访问帐户,我真的不想要它们显示在帐户和同步设置中(虽然这可能不是什么大问题)。

I don't want other applications to have access to the Accounts and I don't really want them showing in the "Accounts and Sync" settings (although maybe that's not a big deal).

所以我的问题是:我应该使用它吗?优点缺点?我可以隐藏其他应用中的帐户并阻止它们出现在帐户和同步中吗?

So my question is: should I use it? Pros/cons? Can I hide the Accounts from other apps and stop them from appearing in "Accounts and Sync"?

推荐答案

这个问题的答案可能对你有所帮助......
我应该如何使用Android AccountManager?

This accepted answer to this question would probably help you... What should I use Android AccountManager for?

还应该指出,如上文所述,以及没有SyncAdapter的AccountManager?,你不能拥有 AccountManager 没有 SyncAdapter ,因此根据您的具体情况使用它可能不太好。

It should also be pointed out, as mentioned in the above post and also in AccountManager without a SyncAdapter? , that you can't have an AccountManager without a SyncAdapter, so its probably not good to use this for your particular situation.

我看不出有任何理由使用 AccountManager 专门用于存储此类信息 - 在一天结束时,与您自己手动存储数据没有什么不同自己的数据库或文件。如果有的话,它可能使事情变得复杂 - 你为什么不把它存储在 SharedPreferences

I can't see any reason to use an AccountManager specifically for storing this type of information - at the end of the day, its no different to manually storing the data yourself in your own database or file. If anything, it probably complicates things - why don't you just store it in SharedPreferences?

唯一的原因我想可以鼓励使用 AccountManager ,如果你想在多个不同的应用程序之间共享你的帐户,因为数据存储在中央Android数据存储区中所有应用都可以访问。但是,如果不需要,我认为使用 SharedPreferences

The only reason I could think of that would encourage the use of AccountManager would be if you want to share your account across a number of different apps, as the data is stored in the central Android datastore which can be accessed by all apps. However, if this isn't required, I think its probably easier and simpler to just use SharedPreferences

这篇关于您是否应该使用AccountManager存储Android应用的用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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