I have an arraylist and I want to save the data, when the app is closed / terminated / destroyed.
//Class SimpleBookManager.java is a singleton
private ArrayList<Book> allBooks = new ArrayList<Book>();
public Book getBook(int index){
return allBooks.get(index);
}
public void saveChanges(){
//Save the allBooks into memory
}
public void loadBooks(){
//Load the allBooks into memory to the variable allBooks;
}
It is reached by writing SimpleBookManager.getSimpleBookManager().saveChanges();
in all the other classes in the package.
What is the best way to implement the method saveChanges() and loadBooks()? Could you give a brief example perhaps? I have read something about shared preferences in android but unfortunately I don't quite get it =)