android如何将对象保存到文件中? [英] android how to save an object to file?

查看:34
本文介绍了android如何将对象保存到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何将对象保存和恢复到 android 上的文件吗?

Does someone know how to save and restore an object to a file on android ?

推荐答案

使用 openFileOutput() ( http://developer.android.com/guide/topics/data/data-storage.html#filesInternal ),而不是使用 ObjectOutputStream ( http://download.oracle.com/javase/1.4.2/docs/api/java/io/ObjectOutputStream.html ) 将您的对象写入文件.

Open a file using openFileOutput() ( http://developer.android.com/guide/topics/data/data-storage.html#filesInternal ), than use an ObjectOutputStream ( http://download.oracle.com/javase/1.4.2/docs/api/java/io/ObjectOutputStream.html ) to write your object to a file.

使用他们邪恶的双胞胎 openFileInput() 和 ObjectInputStream() 来逆转这个过程.

Use their evil twin openFileInput() and ObjectInputStream() to reverse the process.

这篇关于android如何将对象保存到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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