I'm currently developing an Android app that deals with storing book translations. I'm using Firebase to hold all the data online, and I have no trouble pulling data from it and storing them as Book objects. I have a master list of books in the main class that stores all the books from the Firebase database, however the list doesn't seem to update properly.
public static List<Book> books = new ArrayList<Book>();
protected void onCreate(Bundle savedInstanceState) {
    myFirebaseRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            for (DataSnapshot bookSnapshhot : snapshot.getChildren()) {
                Book book = bookSnapshhot.getValue(Book.class);
                books.add(book);
                System.out.println(book.getAuthor() + " - " + book.getTitle());
                for (Chapter chapter : book.getChapters()) {
                    System.out.println(chapter.getTitle());
                }
                for (Genre genre : book.getGenres()) {
                    System.out.println(genre.getGenre());
                }
                System.out.println(books.size());
            }
        }
        @Override public void onCancelled(FirebaseError error) { }
    });
    System.out.println(books.size());
}
In that body, the size of books is correct (right now it is only 1). However if I call the same print statement outside of that code body (the last line), it gives me 0. I don't know why, because it successfully adds it inside the onDataChange() method but it seems to not apply the changes on the outside.
 
     
     
    