问题描述
有人知道如何将对象保存和恢复到 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如何将对象保存到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!