如何添加一个int数组共享preferences? [英] How do I add an int array into shared preferences?

查看:113
本文介绍了如何添加一个int数组共享preferences?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存一个int数组复制到共享preferences。

I am trying to save an int array into the shared preferences.

int myInts[]={1,2,3,4};
SharedPreferences prefs = getSharedPreferences(
                        "Settings", 0);
                SharedPreferences.Editor editor = prefs
                        .edit();
                editor.putInt("savedints", myInts);

由于putInt方法不接受INT数组,我想知道是否有人知道另一种方式来做到这一点。谢谢

Since the putInt method does not accept int arrays, I was wondering if anyone knew another way to do this. Thanks

推荐答案

您可以只添加原始值共享preference ......

you can add only primitive values to sharedpreference ......

请参阅本文档:

http://developer.android.com/reference/android/content/Shared$p$pferences.html

这篇关于如何添加一个int数组共享preferences?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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