android how to save an object to file?

前端 未结 3 2112
醉话见心
醉话见心 2021-02-15 16:01

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

3条回答
  •  眼角桃花
    2021-02-15 16:57

    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.

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

提交回复
热议问题