Example usage for android.net Uri getHost

List of usage examples for android.net Uri getHost

Introduction

In this page you can find the example usage for android.net Uri getHost.

Prototype

@Nullable
public abstract String getHost();

Source Link

Document

Gets the encoded host from the authority for this URI.

Usage

From source file:Main.java

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders.<br>
 * <br>/*w  w w.  j  av a2s .  c o  m*/
 * Callers should check whether the path is local before assuming it
 * represents a local file.
 *
 * @param context The context.
 * @param uri     The Uri to query.
 * @author paulburke
 * @see #isLocal(String)
 * @see #getFile(Context, Uri)
 */
@SuppressLint("NewApi")
public static String getPath(final Context context, final Uri uri) {

    if (DEBUG)
        Log.d(TAG + " File -",
                "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: "
                        + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " + uri.getScheme()
                        + ", Host: " + uri.getHost() + ", Segments: " + uri.getPathSegments().toString());

    final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    // DocumentProvider
    if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }

            // TODO handle non-primary volumes
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {

        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();

        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}

From source file:Main.java

public static boolean urlsMatchOnPath(String url1, String url2) {
    try {//from  ww w. ja v a 2  s.c  o  m
        Uri uri1 = Uri.parse(url1);
        Uri uri2 = Uri.parse(url2);
        String path1 = uri1.getPath();
        String path2 = uri2.getPath();

        if (path1.length() >= 2 && path1.substring(0, 2).equals("//"))
            path1 = path1.substring(1, path1.length());
        if (path2.length() >= 2 && path2.substring(0, 2).equals("//"))
            path2 = path2.substring(1, path2.length());

        if (path1.isEmpty())
            path1 = "/";
        if (path2.isEmpty())
            path2 = "/";

        String host1 = uri1.getHost();
        String host2 = uri2.getHost();
        if (host1.startsWith("www."))
            host1 = host1.substring(4);
        if (host2.startsWith("www."))
            host2 = host2.substring(4);

        return host1.equals(host2) && path1.equals(path2);
    } catch (Exception e) {
        return false;
    }
}

From source file:com.android.volley.Request.java

/**
 * @return The hashcode of the URL's host component, or 0 if there is none.
 *///from   w  w  w. j av  a  2s.  c  om
private static int findDefaultTrafficStatsTag(String url) {
    if (!TextUtils.isEmpty(url)) {
        Uri uri = Uri.parse(url);
        if (uri != null) {
            String host = uri.getHost();
            if (host != null) {
                return host.hashCode();
            }
        }
    }
    return 0;
}

From source file:org.fdroid.fdroid.installer.Installer.java

/**
 * Gets an {@link IntentFilter} for matching events from the install
 * process based on the original download URL as a {@link Uri}.
 *///from   w w  w. ja  v a  2 s .c o  m
public static IntentFilter getInstallIntentFilter(Uri uri) {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Installer.ACTION_INSTALL_STARTED);
    intentFilter.addAction(Installer.ACTION_INSTALL_COMPLETE);
    intentFilter.addAction(Installer.ACTION_INSTALL_INTERRUPTED);
    intentFilter.addAction(Installer.ACTION_INSTALL_USER_INTERACTION);
    intentFilter.addDataScheme(uri.getScheme());
    intentFilter.addDataAuthority(uri.getHost(), String.valueOf(uri.getPort()));
    intentFilter.addDataPath(uri.getPath(), PatternMatcher.PATTERN_LITERAL);
    return intentFilter;
}

From source file:org.brandroid.openmanager.util.FileManager.java

public static OpenPath getOpenCache(String path, Boolean bGetNetworkedFiles, SortType sort) throws IOException //, SmbAuthException, SmbException
{
    if (path == null)
        return null;
    //Logger.LogDebug("Checking cache for " + path);
    if (mOpenCache == null)
        mOpenCache = new Hashtable<String, OpenPath>();
    OpenPath ret = mOpenCache.get(path);
    if (ret == null) {
        if (path.startsWith("ftp:/") && OpenServers.DefaultServers != null) {
            Logger.LogDebug("Checking cache for " + path);
            FTPManager man = new FTPManager(path);
            FTPFile file = new FTPFile();
            file.setName(path.substring(path.lastIndexOf("/") + 1));
            Uri uri = Uri.parse(path);
            OpenServer server = OpenServers.DefaultServers.findByHost("ftp", uri.getHost());
            man.setUser(server.getUser());
            man.setPassword(server.getPassword());
            ret = new OpenFTP(null, file, man);
        } else if (path.startsWith("scp:/")) {
            Uri uri = Uri.parse(path);/*from  ww w.  j  a v a  2 s. com*/
            ret = new OpenSCP(uri.getHost(), uri.getUserInfo(), uri.getPath(), null);
        } else if (path.startsWith("sftp:/") && OpenServers.DefaultServers != null) {
            Uri uri = Uri.parse(path);
            OpenServer server = OpenServers.DefaultServers.findByHost("sftp", uri.getHost());
            ret = new OpenSFTP(uri);
            SimpleUserInfo info = new SimpleUserInfo();
            if (server != null)
                info.setPassword(server.getPassword());
            ((OpenSFTP) ret).setUserInfo(info);
        } else if (path.startsWith("smb:/") && OpenServers.DefaultServers != null) {
            try {
                Uri uri = Uri.parse(path);
                String user = uri.getUserInfo();
                if (user != null && user.indexOf(":") > -1)
                    user = user.substring(0, user.indexOf(":"));
                else
                    user = "";
                OpenServer server = OpenServers.DefaultServers.findByPath("smb", uri.getHost(), user,
                        uri.getPath());
                if (server == null)
                    server = OpenServers.DefaultServers.findByUser("smb", uri.getHost(), user);
                if (server == null)
                    server = OpenServers.DefaultServers.findByHost("smb", uri.getHost());
                if (user == "")
                    user = server.getUser();
                if (server != null && server.getPassword() != null && server.getPassword() != "")
                    user += ":" + server.getPassword();
                if (!user.equals(""))
                    user += "@";
                ret = new OpenSMB(uri.getScheme() + "://" + user + uri.getHost() + uri.getPath());
            } catch (Exception e) {
                Logger.LogError("Couldn't get samba from cache.", e);
            }
        } else if (path.startsWith("/data") || path.startsWith("/system"))
            ret = new OpenFileRoot(new OpenFile(path));
        else if (path.startsWith("/"))
            ret = new OpenFile(path);
        else if (path.startsWith("file://"))
            ret = new OpenFile(path.replace("file://", ""));
        else if (path.equals("Videos"))
            ret = OpenExplorer.getVideoParent();
        else if (path.equals("Photos"))
            ret = OpenExplorer.getPhotoParent();
        else if (path.equals("Music"))
            ret = OpenExplorer.getMusicParent();
        else if (path.equals("Downloads"))
            ret = OpenExplorer.getDownloadParent();
        if (ret == null)
            return ret;
        if (ret instanceof OpenFile && ret.isArchive() && Preferences.Pref_Zip_Internal)
            ret = new OpenZip((OpenFile) ret);
        if (ret.requiresThread() && bGetNetworkedFiles) {
            if (ret.listFiles() != null)
                setOpenCache(path, ret);
        } else if (ret instanceof OpenNetworkPath) {
            if (ret.listFromDb(sort))
                setOpenCache(path, ret);
        }
    }
    //if(ret == null)
    //   ret = setOpenCache(path, new OpenFile(path));
    //else setOpenCache(path, ret);
    return ret;
}

From source file:com.breadwallet.tools.security.RequestHandler.java

public static boolean tryBitIdUri(final Activity app, String uri, JSONObject jsonBody) {
    if (uri == null)
        return false;
    boolean isBitUri = false;

    URI bitIdUri = null;/*ww w  .  ja  v  a 2 s.co m*/
    try {
        bitIdUri = new URI(uri);
        if ("bitid".equals(bitIdUri.getScheme()))
            isBitUri = true;
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    _bitUri = uri;

    if (jsonBody != null) {
        try {
            _authString = jsonBody.getString("prompt_string");
            _bitCallback = jsonBody.getString("bitid_url");
            _index = jsonBody.getInt("bitid_index");
            _strToSign = jsonBody.getString("string_to_sign");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else if (bitIdUri != null && "bitid".equals(bitIdUri.getScheme())) {
        if (app == null) {
            Log.e(TAG, "tryBitIdUri: app is null, returning true still");
            return isBitUri;
        }

        //ask for phrase, will system auth if needed

        _authString = "BitID Authentication Request";
    }

    //        Log.e(TAG, "tryBitIdUri: _bitUri: " + _bitUri);
    //        Log.e(TAG, "tryBitIdUri: _strToSign: " + _strToSign);
    //        Log.e(TAG, "tryBitIdUri: _index: " + _index);

    new Thread(new Runnable() {
        @Override
        public void run() {
            byte[] phrase = null;
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Uri tmpUri = Uri.parse(_bitUri);
            try {
                phrase = KeyStoreManager.getKeyStorePhrase(app, REQUEST_PHRASE_BITID);
                ((BreadWalletApp) app.getApplicationContext()).promptForAuthentication(app, AUTH_FOR_BIT_ID,
                        null, tmpUri.getHost(), _authString, null, false);
            } catch (BRKeystoreErrorException e) {
                //asked the system, no need for local auth
                e.printStackTrace();
            } finally {
                //free the phrase
                if (phrase != null)
                    Arrays.fill(phrase, (byte) 0);
            }
        }
    }).start();
    return isBitUri;

}

From source file:com.iceteck.silicompressorr.FileUtils.java

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders.<br>
 * <br>/*from  w ww . j  a va 2  s  .  co m*/
 * Callers should check whether the path is local before assuming it
 * represents a local file.
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @see #isLocal(String)
 * @see #getFile(Context, Uri)
 * @author paulburke
 */
public static String getPath(final Context context, final Uri uri) {

    if (DEBUG)
        Log.d(TAG + " File -",
                "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: "
                        + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " + uri.getScheme()
                        + ", Host: " + uri.getHost() + ", Segments: " + uri.getPathSegments().toString());

    final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    // DocumentProvider

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {

        // ExternalStorageProvider
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }

            // TODO handle non-primary volumes
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {

        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();

        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}

From source file:org.totschnig.myexpenses.util.FileUtils.java

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders.<br>
 * <br>//from  w w  w.  jav a 2  s  .  c  o m
 * Callers should only use this for display purposes and not for accessing the file directly via the
 * file system
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @see #isLocal(String)
 * @see #getFile(Context, Uri)
 * @author paulburke
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static String getPath(final Context context, final Uri uri) {

    if (DEBUG)
        Log.d(TAG + " File -",
                "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: "
                        + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " + uri.getScheme()
                        + ", Host: " + uri.getHost() + ", Segments: " + uri.getPathSegments().toString());

    // DocumentProvider
    if (isDocumentUri(context, uri)) {
        // ExternalStorageProvider
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                String path = Environment.getExternalStorageDirectory().getPath();
                if (split.length > 1) {
                    path += "/" + split[1];
                }
                return path;
            }
            //there is no documented way of returning a path to a file on non primary storage.
            //so what we do is displaying the documentId to the user which is better than just null
            return docId;
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {

        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();

        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}

From source file:im.vector.receiver.VectorUniversalLinkReceiver.java

/***
 * Tries to parse an universal link.//w ww  .  j  a  va 2s. c om
 *
 * @param uri the uri to parse
 * @return the universal link items, null if the universal link is invalid
 */
public static HashMap<String, String> parseUniversalLink(Uri uri) {
    HashMap<String, String> map = null;

    try {
        // sanity check
        if ((null == uri) || TextUtils.isEmpty(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : null");
            return null;
        }

        if (!TextUtils.equals(uri.getHost(), "vector.im") && !TextUtils.equals(uri.getHost(), "riot.im")
                && !TextUtils.equals(uri.getHost(), "matrix.to")) {
            Log.e(LOG_TAG, "## parseUniversalLink : unsupported host " + uri.getHost());
            return null;
        }

        boolean isSupportedHost = TextUtils.equals(uri.getHost(), "vector.im")
                || TextUtils.equals(uri.getHost(), "riot.im");

        // when the uri host is vector.im, it is followed by a dedicated path
        if (isSupportedHost && !mSupportedVectorLinkPaths.contains(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported");
            return null;
        }

        // remove the server part
        String uriFragment;
        if (null != (uriFragment = uri.getFragment())) {
            uriFragment = uriFragment.substring(1); // get rid of first "/"
        } else {
            Log.e(LOG_TAG, "## parseUniversalLink : cannot extract path");
            return null;
        }

        String temp[] = uriFragment.split("/", 3); // limit to 3 for security concerns (stack overflow injection)

        if (!isSupportedHost) {
            ArrayList<String> compliantList = new ArrayList<>(Arrays.asList(temp));
            compliantList.add(0, "room");
            temp = compliantList.toArray(new String[compliantList.size()]);
        }

        if (temp.length < 2) {
            Log.e(LOG_TAG, "## parseUniversalLink : too short");
            return null;
        }

        if (!TextUtils.equals(temp[0], "room") && !TextUtils.equals(temp[0], "user")) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported " + temp[0]);
            return null;
        }

        map = new HashMap<>();

        String firstParam = temp[1];

        if (MXSession.isUserId(firstParam)) {
            if (temp.length > 2) {
                Log.e(LOG_TAG, "## parseUniversalLink : universal link to member id is too long");
                return null;
            }

            map.put(ULINK_MATRIX_USER_ID_KEY, firstParam);
        } else if (MXSession.isRoomAlias(firstParam) || MXSession.isRoomId(firstParam)) {
            map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, firstParam);
        } else if (MXSession.isGroupId(firstParam)) {
            map.put(ULINK_GROUP_ID_KEY, firstParam);
        }

        // room id only ?
        if (temp.length > 2) {
            String eventId = temp[2];

            if (MXSession.isMessageId(eventId)) {
                map.put(ULINK_EVENT_ID_KEY, temp[2]);
            } else {
                uri = Uri.parse(uri.toString().replace("#/room/", "room/"));

                map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, uri.getLastPathSegment());

                Set<String> names = uri.getQueryParameterNames();

                for (String name : names) {
                    String value = uri.getQueryParameter(name);

                    try {
                        value = URLDecoder.decode(value, "UTF-8");
                    } catch (Exception e) {
                        Log.e(LOG_TAG, "## parseUniversalLink : URLDecoder.decode " + e.getMessage());
                        return null;
                    }

                    map.put(name, value);
                }
            }
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "## parseUniversalLink : crashes " + e.getLocalizedMessage());
    }

    // check if the parsing succeeds
    if ((null != map) && (map.size() < 1)) {
        Log.e(LOG_TAG, "## parseUniversalLink : empty dictionary");
        return null;
    }

    return map;
}

From source file:fpt.isc.nshreport.utilities.FileUtils.java

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders.<br>
 * <br>/*from  ww w.ja va  2 s.co m*/
 * Callers should check whether the path is local before assuming it
 * represents a local file.
 *
 * @param context The context.
 * @param uri     The Uri to query.
 * @author paulburke
 * @see #isLocal(String)
 * @see #getFile(Context, Uri)
 */
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String getPath(final Context context, final Uri uri) {

    if (DEBUG)
        Log.d(TAG + " File -",
                "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: "
                        + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " + uri.getScheme()
                        + ", Host: " + uri.getHost() + ", Segments: " + uri.getPathSegments().toString());

    final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    // DocumentProvider
    if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
        // LocalStorageProvider
        //if (isLocalStorageDocument(uri)) {
        if (false) {
            // The path is the id
            return DocumentsContract.getDocumentId(uri);
        }
        // ExternalStorageProvider
        else if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }

            // TODO handle non-primary volumes
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {

        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();

        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}