SharedPreferences 名称是否需要唯一? [英] Does SharedPreferences name need to be unique?

查看:35
本文介绍了SharedPreferences 名称是否需要唯一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个愚蠢的问题,但我正在使用一个 SharedPreference,其中包含几个不同的名称MyPrefs1"、MyPrefs2"等

Probably a dumb question, but I"m using a SharedPreference with a few different names "MyPrefs1", "MyPrefs2" etc.

我假设这仅限于我的应用程序.即如果其他应用程序尝试使用相同的名称,它不会覆盖我的值

I'm assuming this is restricted to my app. i.e. if some other app tries to use the same name, it won't overwrite my values

我几乎相信我的理解是正确的,但名称SharedPreferences"似乎表明它可以在应用程序之间共享?(是否用于活动之间的共享?)

I pretty much believe my understanding is correct, but the name "SharedPreferences" seem to indicate that it can be shared between apps? (is it for Sharing between activities?)

推荐答案

没错,SharedPreferences 存储在您应用的私有文件夹中(确切地说,在/data/data/your package name/shared_prefs 中).

That's correct, the SharedPreferences are stored in your app's private folder (to be exact, in /data/data/your package name/shared_prefs).

你可以给他们任何你想要的名字.

You can give them whatever name you want.

这篇关于SharedPreferences 名称是否需要唯一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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