+ operations = prepareInsertShares(shares, operations);
+ }
+
+ // apply operations in batch
+ if (operations.size() > 0) {
+ Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
+ try {
+ if (getContentResolver() != null) {
+ getContentResolver().applyBatch(MainApp.getAuthority(), operations);
+
+ } else {
+ getContentProviderClient().applyBatch(operations);
+ }
+
+ } catch (OperationApplicationException e) {
+ Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
+
+ } catch (RemoteException e) {
+
+ }
+ }
+
+ }
+
+ /**
+ * Prepare operations to insert or update files to save in the given folder
+ * @param shares List of shares to insert
+ * @param operations List of operations
+ * @return
+ */
+ private ArrayList<ContentProviderOperation> prepareInsertShares(
+ ArrayList<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
+
+ if (shares != null) {
+ // prepare operations to insert or update files to save in the given folder