Android examples for android.support.v4.util:AtomicFile
save List to AtomicFile
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.util.List; import android.support.v4.util.AtomicFile; public class Main { public static <T> void saveList(File file, List<T> data) throws Exception { AtomicFile atom = new AtomicFile(file); FileOutputStream stream = atom.startWrite(); try {/*from w w w .j a v a 2 s . c o m*/ ObjectOutputStream out = new ObjectOutputStream(stream); out.writeObject(data); atom.finishWrite(stream); } catch (Exception e) { atom.failWrite(stream); throw e; } } }