Back to project page assignment1_todolist.
The source code is released under:
GNU General Public License
If you think the Android project assignment1_todolist listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.mswillia_notes002; /*w w w . j a v a 2s. c om*/ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import android.content.Context; import android.util.Log; public class TodoListFileManager implements InterfaceFileManager{ // TodoListFileManager class implements saving/loading of a single CombinedList object containing the todo list and archive list //XXX Portions of class borrowed from CMPUT301 Lonely Twitter lab tutorial XXX private static final String FILENAME = "todolist.sav"; private Context context; public TodoListFileManager(Context context) { this.context = context; } public void saveTodoList(CombinedList cl) { try { FileOutputStream fileoutputstream = context.openFileOutput(FILENAME, Context.MODE_PRIVATE); ObjectOutputStream objectoutputstream = new ObjectOutputStream(fileoutputstream); objectoutputstream.writeObject(cl); objectoutputstream.close(); fileoutputstream.close(); } catch (Exception e) { e.printStackTrace(); } } public CombinedList loadTodoList(){ CombinedList cl = new CombinedList(); try { FileInputStream fileinputstream = context.openFileInput(FILENAME); ObjectInputStream objectinputstream = new ObjectInputStream(fileinputstream); cl = (CombinedList) objectinputstream.readObject(); //we assume the input file contains a combined todo list objectinputstream.close(); fileinputstream.close(); } catch (Exception e) { Log.i("TodoList", "Input stream is not proper Todo list"); e.printStackTrace(); } return cl; } }