Android Open Source - rtwong-notes Data Manager






From Project

Back to project page rtwong-notes.

License

The source code is released under:

GNU General Public License

If you think the Android project rtwong-notes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ca.ualberta.cs.rtwong_notes;
/*www.j  av a 2s .  com*/
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import android.content.Context;
import android.util.Log;


// utility class that saves and loads ToDoList 
public class DataManager extends MainActivity {

  private static final String FILENAME = "rtwongfile.sav";
  
  private Context context;
  
  public DataManager(Context appContext) {
    context = appContext;
  }
  
  
    public ToDoList load() {
      ToDoList todoList = new ToDoList();
      try {
        FileInputStream fis = context.openFileInput(FILENAME);
        ObjectInputStream ois = new ObjectInputStream(fis);
        todoList = (ToDoList) ois.readObject();
        fis.close();
        ois.close();
      } catch (Exception e) {
        Log.i("rtwong-notes", "Error casting");
        e.printStackTrace();
      } 
      return todoList;
    }
    
    public void save(ToDoList todoList) {
      try {
        FileOutputStream fos = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(todoList);
        fos.close();
        oos.close();
      } 
      catch (Exception e) {
        e.printStackTrace();
      }
    }
}




Java Source Code List

ca.ualberta.cs.rtwong_notes.ArchiveActivity.java
ca.ualberta.cs.rtwong_notes.DataManager.java
ca.ualberta.cs.rtwong_notes.EmailActivity.java
ca.ualberta.cs.rtwong_notes.EmailArchived.java
ca.ualberta.cs.rtwong_notes.EmailCurrent.java
ca.ualberta.cs.rtwong_notes.MainActivity.java
ca.ualberta.cs.rtwong_notes.SummaryActivity.java
ca.ualberta.cs.rtwong_notes.ToDoList.java
ca.ualberta.cs.rtwong_notes.ToDo.java