public void persistRecipes(final Collection<Recipe> recipes) throws RemoteException, OperationApplicationException { ArrayList<ContentProviderOperation> operations = Lists.newArrayList(); for (Recipe recipe : recipes) { operations.add( ContentProviderOperation.newInsert(RecipeContract.CONTENT_URI) .withValues(ContentMapper.toContentValues(recipe)) .build()); String recipeId = recipe.getId(); Collection<Ingredient> ingredients = recipe.getIngredients(); for (Ingredient ingredient : ingredients) { operations.add( ContentProviderOperation.newInsert(IngredientContract.CONTENT_URI) .withValues(ContentMapper.toContentValues(ingredient, recipeId)) .build()); String ingredientId = ingredient.getId(); Collection<Element> elements = ingredient.getElements(); for (Element element : elements) { operations.add( ContentProviderOperation.newInsert(ElementContract.CONTENT_URI) .withValues(ContentMapper.toContentValues(element, recipeId, ingredientId)) .build()); } } } contentResolver.applyBatch(AppContentProvider.AUTHORITY, operations); }