1 2 3 4 5 6 7 8 9 10 11 12 13
|
public static void saveData(final Object data) throws IOException{
FileOutputStream fos = context.openFileOutput(Filename, Context.MODE_WORLD_READABLE |Context.MODE_WORLD_WRITEABLE);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(data);
oos.close();
}
public static Object readData() throws StreamCorruptedException, IOException, ClassNotFoundException{
FileInputStream fis = context.openFileInput(Filename);
ObjectInputStream ois = new ObjectInputStream(fis);
return ois.readObject();
} |
Partager