Skip to content

Instantly share code, notes, and snippets.

@cosbor11
Created April 3, 2017 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosbor11/759690ec689f49873304d1c00337c91b to your computer and use it in GitHub Desktop.
Save cosbor11/759690ec689f49873304d1c00337c91b to your computer and use it in GitHub Desktop.
Persist data within an Android application
final CookBook cookBook = new CookBook();
cookBook.setTitle("Onyx's House of Yummy");
final Recipe cupOfNoodle = new Recipe();
cupOfNoodle.setContent("Cup of Noodle");
cupOfNoodle.setDetails("Open lid, add water, put powder stuff in and microwave until it boils over and makes a mess in your microwave.");
List<Recipe> recipees = new ArrayList<>();
recipees.add(cupOfNoodle);
cookBook.setRecipes(recipees);
try {
persistenceManager.saveEntity(cookBook);
} catch (EntityException e) {
Log.e(TAG, "Could not persist cookbook");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment