字符串的共享preferences阵列阵列、字符串、preferences

由网友(第一场雪我陪你)分享简介:我想知道是否有可能存储的字符串数组中的共享preferences 。在我的应用程序,我想,设置名称进行存储。我知道这可以通过使用数据库来完成,我只是想知道是否有可能,以拯救那些设置的名称作为字符串中的共享preferences阵列。I wanna know whether is it possible to stor...

我想知道是否有可能存储的字符串数组中的共享preferences 。在我的应用程序,我想,设置名称进行存储。我知道这可以通过使用数据库来完成,我只是想知道是否有可能,以拯救那些设置的名称作为字符串中的共享preferences阵列。

I wanna know whether is it possible to store array of string in the SharedPreferences. In my application i want , set of names to be stored. I know this can be done using DB,i just wanna know whether is it possible to save those set of name as array of strings in the SharedPreferences.

推荐答案

您可以在API级别11和更高的使用共享preferences 商店设置字符串。请参阅getStringSet()和putStringSet()ю

You can store set of String using SharedPreferences in API Level 11 and higher. See getStringSet() and putStringSet()ю

在API级别前11,你可以使用一些黑客。例如,如果你需要存储在密钥字符串数组的字符串数组的,你可以使用保存每个字符串由数组 putString 键,按键的 stringArray.1的stringArray.2的,等等。

In API Level prior to 11 you can use some kind of hack. For example, if you need to store string array under key "stringArray", you can save each string from array using putString and keys "stringArray.1", "stringArray.2", so on.

阅读全文

相关推荐

最新文章