如何保存简单对象数组在我的Andr​​oid应用程序? [英] How to save an array of simple objects in my android app?

查看:178
本文介绍了如何保存简单对象数组在我的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建我的第一个Android应用程序,我已经一个简单的类'球员'我要救的那几个实例(十几或二)由5个整数的。我只想使用它们是用户能够保存和加载球员。

I'm currently creating my first android app and I've a simple class 'Player' I want to save a few instances (a dozen or two) of that consist of 5 ints. All I wish to use them for is for the user to be able to save and load players.

我目前有点莫名其妙如何做到这一点的谷歌搜索和搜索这个网站返回Parcelable,序列化,JSON,外部化,SQL,XML简单,共享preferences和许多技术都具有正反和缺点看起来很复杂,做工考虑到他们可能会很慢或可能无法正常工作,或不适合于什么,我希望做的简易性。

I'm currently a bit bewildered as to how to do this as googling and searching this site returns Parcelable, Serializable, JSON, Externalizable, SQL, Simple XML, shared preferences and many more techniques all of which have pros and cons and look quite complex to work given they may be slow or might not work or not be suited to the simplicity of what I wish to do.

什么办法COM pression和存储我应该考虑?
谢谢

What approach of compression and storage should I be taking? Thanks

推荐答案

如果你想简单的解决方案,然后用 JSON 共享$ P $走pferences 。容易解析,更容易储存。

If you want easier solution then go with JSON or SharedPreferences. Easier to parse and easier to store.

下面是一个例子code我已经上传你。 ObjectSavingTest

Here is an example code I've uploaded for you. ObjectSavingTest

这篇关于如何保存简单对象数组在我的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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