List of usage examples for android.content OperationApplicationException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.lentitems.LentItemDisplayFragment.java
/** * The dummyApplyBatch method is only used to show a sample batch. * It's not used within this sample app. *//* w w w. ja va 2s . c om*/ @SuppressWarnings("unused") private void dummyApplyBatch() { String borrower = "John Doe"; String item = "Anhalter"; boolean hasPic = true; Context ctx = getActivity(); String somePath = ctx.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath(); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(Items.CONTENT_URI).withValue(Items.NAME, item) .withValue(Items.BORROWER, borrower).build()); if (hasPic) { ops.add(ContentProviderOperation.newInsert(Photos.CONTENT_URI).withValue(Photos._DATA, somePath) .withValueBackReference(Photos.ITEMS_ID, 0).build()); } try { ContentResolver resolver = getActivity().getContentResolver(); resolver.applyBatch(LentItemsContract.AUTHORITY, ops); } catch (OperationApplicationException e) { Log.e("wemonit", "cannot apply batch: " + e.getLocalizedMessage(), e); } catch (RemoteException e) { Log.e("wemonit", "cannot apply batch: " + e.getLocalizedMessage(), e); } // EventBus.getDefault().post(whatever); }