Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android how to save an object to file?

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

like image 321
Fabien Avatar asked Sep 02 '10 08:09

Fabien


1 Answers

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.

like image 71
yayay Avatar answered Sep 20 '22 00:09

yayay