Example usage for android.os RemoteException getMessage

List of usage examples for android.os RemoteException getMessage

Introduction

In this page you can find the example usage for android.os RemoteException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

private boolean fileExists(String cmp_key, String value) {
    Cursor c;//w  ww.  j  ava2  s .  c o m
    if (getContentResolver() != null) {
        c = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null,
                cmp_key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
                new String[] { value, mAccount.name }, null);
    } else {
        try {
            c = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI, null,
                    cmp_key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
                    new String[] { value, mAccount.name }, null);
        } catch (RemoteException e) {
            Log_OC.e(TAG, "Couldn't determine file existance, assuming non existance: " + e.getMessage());
            return false;
        }
    }
    boolean retval = false;
    if (c != null) {
        retval = c.moveToFirst();
        c.close();
    }
    return retval;
}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

public void deleteFileInMediaScan(String path) {

    String mimetypeString = FileStorageUtils.getMimeTypeFromName(path);
    ContentResolver contentResolver = getContentResolver();

    if (contentResolver != null) {
        if (mimetypeString.startsWith("image/")) {
            // Images
            contentResolver.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                    MediaStore.Images.Media.DATA + "=?", new String[] { path });
        } else if (mimetypeString.startsWith("audio/")) {
            // Audio
            contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    MediaStore.Audio.Media.DATA + "=?", new String[] { path });
        } else if (mimetypeString.startsWith("video/")) {
            // Video
            contentResolver.delete(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                    MediaStore.Video.Media.DATA + "=?", new String[] { path });
        }//from  w  w  w  . j  a v a2s. c  o m
    } else {
        ContentProviderClient contentProviderClient = getContentProviderClient();
        try {
            if (mimetypeString.startsWith("image/")) {
                // Images
                contentProviderClient.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Images.Media.DATA + "=?", new String[] { path });
            } else if (mimetypeString.startsWith("audio/")) {
                // Audio
                contentProviderClient.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Audio.Media.DATA + "=?", new String[] { path });
            } else if (mimetypeString.startsWith("video/")) {
                // Video
                contentProviderClient.delete(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Video.Media.DATA + "=?", new String[] { path });
            }
        } catch (RemoteException e) {
            Log_OC.e(TAG, "Exception deleting media file in MediaStore " + e.getMessage());
        }
    }

}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

public boolean saveShare(OCShare share) {
    boolean overriden = false;
    ContentValues cv = new ContentValues();
    cv.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
    cv.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
    cv.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());
    cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith());
    cv.put(ProviderTableMeta.OCSHARES_PATH, share.getPath());
    cv.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions());
    cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
    cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
    cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
    cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
    cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
    cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
    cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
    cv.put(ProviderTableMeta.OCSHARES_NAME, share.getName());
    cv.put(ProviderTableMeta.OCSHARES_URL, share.getShareLink());
    cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);

    if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
        overriden = true;//from w  ww  .  j av a 2  s. co m
        if (getContentResolver() != null) {
            getContentResolver().update(ProviderTableMeta.CONTENT_URI_SHARE, cv,
                    ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?",
                    new String[] { String.valueOf(share.getRemoteId()) });
        } else {
            try {
                getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_SHARE, cv,
                        ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?",
                        new String[] { String.valueOf(share.getRemoteId()) });
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage());
            }
        }
    } else {
        Uri result_uri = null;
        if (getContentResolver() != null) {
            result_uri = getContentResolver().insert(ProviderTableMeta.CONTENT_URI_SHARE, cv);
        } else {
            try {
                result_uri = getContentProviderClient().insert(ProviderTableMeta.CONTENT_URI_SHARE, cv);
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage());
            }
        }
        if (result_uri != null) {
            long new_id = Long.parseLong(result_uri.getPathSegments().get(1));
            share.setId(new_id);
        }
    }

    return overriden;
}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

public boolean saveFile(OCFile file) {
    boolean overriden = false;
    ContentValues cv = new ContentValues();
    cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
    cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
            file.getModificationTimestampAtLastSyncForData());
    cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
    cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
    cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype());
    cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
    cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
    cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
    if (!file.isFolder())
        cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
    cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
    cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
    cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
    cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
    cv.put(ProviderTableMeta.FILE_TREE_ETAG, file.getTreeEtag());
    cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
    cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
    cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
    cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
    cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
    cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
    cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
    cv.put(ProviderTableMeta.FILE_PRIVATE_LINK, file.getPrivateLink());

    boolean sameRemotePath = fileExists(file.getRemotePath());
    if (sameRemotePath || fileExists(file.getFileId())) { // for renamed files; no more delete and create

        OCFile oldFile;//  ww  w  . jav  a 2 s .  c  o  m
        if (sameRemotePath) {
            oldFile = getFileByPath(file.getRemotePath());
            file.setFileId(oldFile.getFileId());
        } else {
            oldFile = getFileById(file.getFileId());
        }

        overriden = true;
        if (getContentResolver() != null) {
            getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?",
                    new String[] { String.valueOf(file.getFileId()) });
        } else {
            try {
                getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv,
                        ProviderTableMeta._ID + "=?", new String[] { String.valueOf(file.getFileId()) });
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage());
            }
        }

    } else {
        // new file

        setInitialAvailableOfflineStatus(file, cv);

        Uri result_uri = null;
        if (getContentResolver() != null) {
            result_uri = getContentResolver().insert(ProviderTableMeta.CONTENT_URI_FILE, cv);
        } else {
            try {
                result_uri = getContentProviderClient().insert(ProviderTableMeta.CONTENT_URI_FILE, cv);
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage());
            }
        }
        if (result_uri != null) {
            long new_id = Long.parseLong(result_uri.getPathSegments().get(1));
            file.setFileId(new_id);
        }
    }

    return overriden;
}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

public OCCapability saveCapabilities(OCCapability capability) {

    // Prepare capabilities data
    ContentValues cv = new ContentValues();
    cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, mAccount.name);
    cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, capability.getVersionMayor());
    cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, capability.getVersionMinor());
    cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
    cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
    cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
    cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollinterval());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED,
            capability.getFilesSharingApiEnabled().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
            capability.getFilesSharingPublicEnabled().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED,
            capability.getFilesSharingPublicPasswordEnforced().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED,
            capability.getFilesSharingPublicExpireDateEnabled().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS,
            capability.getFilesSharingPublicExpireDateDays());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED,
            capability.getFilesSharingPublicExpireDateEnforced().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL,
            capability.getFilesSharingPublicSendMail().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD,
            capability.getFilesSharingPublicUpload().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_MULTIPLE,
            capability.getFilesSharingPublicMultiple().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY,
            capability.getFilesSharingPublicSupportsUploadOnly().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL,
            capability.getFilesSharingUserSendMail().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_RESHARING, capability.getFilesSharingResharing().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING,
            capability.getFilesSharingFederationOutgoing().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING,
            capability.getFilesSharingFederationIncoming().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING,
            capability.getFilesBigFileChuncking().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_FILES_UNDELETE, capability.getFilesUndelete().getValue());
    cv.put(ProviderTableMeta.CAPABILITIES_FILES_VERSIONING, capability.getFilesVersioning().getValue());

    if (capabilityExists(mAccount.name)) {
        if (getContentResolver() != null) {
            getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv,
                    ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?", new String[] { mAccount.name });
        } else {//from  w w  w. j  a v a2s  .  com
            try {
                getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv,
                        ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?", new String[] { mAccount.name });
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage());
            }
        }
    } else {
        Uri result_uri = null;
        if (getContentResolver() != null) {
            result_uri = getContentResolver().insert(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv);
        } else {
            try {
                result_uri = getContentProviderClient().insert(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv);
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Fail to insert insert capability to database " + e.getMessage());
            }
        }
        if (result_uri != null) {
            long new_id = Long.parseLong(result_uri.getPathSegments().get(1));
            capability.setId(new_id);
            capability.setAccountName(mAccount.name);
        }
    }

    return capability;
}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

/**
 * Updates database and file system for a file or folder that was moved to a different location.
 *
 * TODO explore better (faster) implementations
 * TODO throw exceptions up !//w  ww  . j  a va2 s. co m
 */
public void moveLocalFile(OCFile file, String targetPath, String targetParentPath) {

    if (file != null && file.fileExists() && !OCFile.ROOT_PATH.equals(file.getFileName())) {

        OCFile targetParent = getFileByPath(targetParentPath);
        if (targetParent == null) {
            throw new IllegalStateException("Parent folder of the target path does not exist!!");
        }

        /// 1. get all the descendants of the moved element in a single QUERY
        Cursor c = null;
        if (getContentProviderClient() != null) {
            try {
                c = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI, null,
                        ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH
                                + " LIKE ? ",
                        new String[] { mAccount.name, file.getRemotePath() + "%" },
                        ProviderTableMeta.FILE_PATH + " ASC ");
            } catch (RemoteException e) {
                Log_OC.e(TAG, e.getMessage());
            }

        } else {
            c = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null,
                    ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ",
                    new String[] { mAccount.name, file.getRemotePath() + "%" },
                    ProviderTableMeta.FILE_PATH + " ASC ");
        }

        List<String> originalPathsToTriggerMediaScan = new ArrayList<>();
        List<String> newPathsToTriggerMediaScan = new ArrayList<>();
        String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);

        /// 2. prepare a batch of update operations to change all the descendants
        if (c != null) {
            ArrayList<ContentProviderOperation> operations = new ArrayList<>(c.getCount());
            if (c.moveToFirst()) {
                int lengthOfOldPath = file.getRemotePath().length();
                int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
                do {
                    ContentValues cv = new ContentValues(); // keep construction in the loop
                    OCFile child = createFileInstance(c);
                    cv.put(ProviderTableMeta.FILE_PATH,
                            targetPath + child.getRemotePath().substring(lengthOfOldPath));
                    if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) {
                        // update link to downloaded content - but local move is not done here!
                        String targetLocalPath = defaultSavePath + targetPath
                                + child.getStoragePath().substring(lengthOfOldStoragePath);

                        cv.put(ProviderTableMeta.FILE_STORAGE_PATH, targetLocalPath);

                        originalPathsToTriggerMediaScan.add(child.getStoragePath());
                        newPathsToTriggerMediaScan.add(targetLocalPath);

                    }
                    if (targetParent
                            .getAvailableOfflineStatus() != OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE) {
                        // moving to an available offline subfolder
                        cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC,
                                OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE_PARENT.getValue());

                    } else {
                        // moving to a not available offline subfolder - with care
                        if (file.getAvailableOfflineStatus() == OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE_PARENT) {
                            cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC,
                                    OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE.getValue());
                        }
                    }

                    if (child.getRemotePath().equals(file.getRemotePath())) {
                        cv.put(ProviderTableMeta.FILE_PARENT, targetParent.getFileId());
                    }
                    operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI)
                            .withValues(cv).withSelection(ProviderTableMeta._ID + "=?",
                                    new String[] { String.valueOf(child.getFileId()) })
                            .build());

                } while (c.moveToNext());
            }
            c.close();

            /// 3. apply updates in batch
            try {
                if (getContentResolver() != null) {
                    getContentResolver().applyBatch(MainApp.getAuthority(), operations);

                } else {
                    getContentProviderClient().applyBatch(operations);
                }

            } catch (Exception e) {
                Log_OC.e(TAG, "Fail to update " + file.getFileId() + " and descendants in database", e);
            }
        }

        /// 4. move in local file system
        String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
        String targetLocalPath = defaultSavePath + targetPath;
        File localFile = new File(originalLocalPath);
        boolean renamed = false;
        if (localFile.exists()) {
            File targetFile = new File(targetLocalPath);
            File targetFolder = targetFile.getParentFile();
            if (!targetFolder.exists()) {
                targetFolder.mkdirs();
            }
            renamed = localFile.renameTo(targetFile);
        }

        if (renamed) {
            Iterator<String> it = originalPathsToTriggerMediaScan.iterator();
            while (it.hasNext()) {
                // Notify MediaScanner about removed file
                deleteFileInMediaScan(it.next());
            }
            it = newPathsToTriggerMediaScan.iterator();
            while (it.hasNext()) {
                // Notify MediaScanner about new file/folder
                triggerMediaScan(it.next());
            }
        }
    }

}

From source file:com.owncloud.android.datamodel.FileDataStorageManager.java

public void saveConflict(OCFile file, String etagInConflict) {
    if (!file.isDown()) {
        etagInConflict = null;/* ww  w. ja  v a 2 s  .c  o m*/
    }
    ContentValues cv = new ContentValues();
    cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
    int updated = 0;
    if (getContentResolver() != null) {
        updated = getContentResolver().update(ProviderTableMeta.CONTENT_URI_FILE, cv,
                ProviderTableMeta._ID + "=?", new String[] { String.valueOf(file.getFileId()) });
    } else {
        try {
            updated = getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_FILE, cv,
                    ProviderTableMeta._ID + "=?", new String[] { String.valueOf(file.getFileId()) });
        } catch (RemoteException e) {
            Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage());
        }
    }

    Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated);

    if (updated > 0) {
        if (etagInConflict != null) {
            /// set conflict in all ancestor folders

            long parentId = file.getParentId();
            Set<String> ancestorIds = new HashSet<String>();
            while (parentId != FileDataStorageManager.ROOT_PARENT_ID) {
                ancestorIds.add(Long.toString(parentId));
                parentId = getFileById(parentId).getParentId();
            }

            if (ancestorIds.size() > 0) {
                StringBuffer whereBuffer = new StringBuffer();
                whereBuffer.append(ProviderTableMeta._ID).append(" IN (");
                for (int i = 0; i < ancestorIds.size() - 1; i++) {
                    whereBuffer.append("?,");
                }
                whereBuffer.append("?");
                whereBuffer.append(")");

                if (getContentResolver() != null) {
                    updated = getContentResolver().update(ProviderTableMeta.CONTENT_URI_FILE, cv,
                            whereBuffer.toString(), ancestorIds.toArray(new String[] {}));
                } else {
                    try {
                        updated = getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_FILE, cv,
                                whereBuffer.toString(), ancestorIds.toArray(new String[] {}));
                    } catch (RemoteException e) {
                        Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage());
                    }
                }
            } // else file is ROOT folder, no parent to set in conflict

        } else {
            /// update conflict in ancestor folders
            // (not directly unset; maybe there are more conflicts below them)
            String parentPath = file.getRemotePath();
            if (parentPath.endsWith(OCFile.PATH_SEPARATOR)) {
                parentPath = parentPath.substring(0, parentPath.length() - 1);
            }
            parentPath = parentPath.substring(0, parentPath.lastIndexOf(OCFile.PATH_SEPARATOR) + 1);

            Log_OC.d(TAG, "checking parents to remove conflict; STARTING with " + parentPath);
            while (parentPath.length() > 0) {

                String whereForDescencentsInConflict = ProviderTableMeta.FILE_ETAG_IN_CONFLICT
                        + " IS NOT NULL AND " + ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND "
                        + ProviderTableMeta.FILE_ACCOUNT_OWNER + " = ? AND " + ProviderTableMeta.FILE_PATH
                        + " LIKE ?";
                Cursor descendantsInConflict = null;
                if (getContentResolver() != null) {
                    descendantsInConflict = getContentResolver().query(ProviderTableMeta.CONTENT_URI_FILE,
                            new String[] { ProviderTableMeta._ID }, whereForDescencentsInConflict,
                            new String[] { mAccount.name, parentPath + "%" }, null);
                } else {
                    try {
                        descendantsInConflict = getContentProviderClient().query(
                                ProviderTableMeta.CONTENT_URI_FILE, new String[] { ProviderTableMeta._ID },
                                whereForDescencentsInConflict, new String[] { mAccount.name, parentPath + "%" },
                                null);
                    } catch (RemoteException e) {
                        Log_OC.e(TAG, "Failed querying for descendants in conflict " + e.getMessage());
                    }
                }
                if (descendantsInConflict == null || descendantsInConflict.getCount() == 0) {
                    Log_OC.d(TAG, "NO MORE conflicts in " + parentPath);
                    if (getContentResolver() != null) {
                        updated = getContentResolver().update(
                                ProviderTableMeta.CONTENT_URI_FILE, cv, ProviderTableMeta.FILE_ACCOUNT_OWNER
                                        + "=? AND " + ProviderTableMeta.FILE_PATH + "=?",
                                new String[] { mAccount.name, parentPath });
                    } else {
                        try {
                            updated = getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_FILE, cv,
                                    ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND "
                                            + ProviderTableMeta.FILE_PATH + "=?",
                                    new String[] { mAccount.name, parentPath });
                        } catch (RemoteException e) {
                            Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage());
                        }
                    }

                } else {
                    Log_OC.d(TAG, "STILL " + descendantsInConflict.getCount() + " in " + parentPath);
                }

                if (descendantsInConflict != null) {
                    descendantsInConflict.close();
                }

                parentPath = parentPath.substring(0, parentPath.length() - 1); // trim last /
                parentPath = parentPath.substring(0, parentPath.lastIndexOf(OCFile.PATH_SEPARATOR) + 1);
                Log_OC.d(TAG, "checking parents to remove conflict; NEXT " + parentPath);
            }
        }
    }

}