Java Code Examples for android.content.UriPermission#getUri()

The following examples show how to use android.content.UriPermission#getUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAFManager.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private Uri getRootUri(String docId){
    Uri treeUri;
    final int splitIndex = docId.indexOf(':', 1);
    final String tag = docId.substring(0, splitIndex);

    //check in cache
    treeUri = secondaryRoots.get(tag);
    if(null != treeUri){
        return treeUri;
    }

    //get root dynamically
    List<UriPermission> permissions = mContext.getContentResolver().getPersistedUriPermissions();
    for (UriPermission permission :
            permissions) {
        String treeRootId = getRootUri(permission.getUri());
        if(docId.startsWith(treeRootId)){
            treeUri = permission.getUri();
            secondaryRoots.put(tag, treeUri);
            return treeUri;
        }
    }
    return treeUri;
}
 
Example 2
Source File: SAFManager.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private Uri getRootUri(String docId){
    Uri treeUri;
    final int splitIndex = docId.indexOf(':', 1);
    final String tag = docId.substring(0, splitIndex);

    //check in cache
    treeUri = secondaryRoots.get(tag);
    if(null != treeUri){
        return treeUri;
    }

    //get root dynamically
    List<UriPermission> permissions = mContext.getContentResolver().getPersistedUriPermissions();
    for (UriPermission permission :
            permissions) {
        String treeRootId = getRootUri(permission.getUri());
        if(docId.startsWith(treeRootId)){
            treeUri = permission.getUri();
            secondaryRoots.put(tag, treeUri);
            return treeUri;
        }
    }
    return treeUri;
}
 
Example 3
Source File: SAFManager.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private Uri getRootUri(String docId){
    Uri treeUri;
    final int splitIndex = docId.indexOf(':', 1);
    final String tag = docId.substring(0, splitIndex);

    //check in cache
    treeUri = secondaryRoots.get(tag);
    if(null != treeUri){
        return treeUri;
    }

    //get root dynamically
    List<UriPermission> permissions = mContext.getContentResolver().getPersistedUriPermissions();
    for (UriPermission permission :
            permissions) {
        String treeRootId = getRootUri(permission.getUri());
        if(docId.startsWith(treeRootId)){
            treeUri = permission.getUri();
            secondaryRoots.put(tag, treeUri);
            return treeUri;
        }
    }
    return treeUri;
}