Example usage for android.net Uri getPath

List of usage examples for android.net Uri getPath

Introduction

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

Prototype

@Nullable
public abstract String getPath();

Source Link

Document

Gets the decoded path.

Usage

From source file:Main.java

public static String getPathFromUri(Uri contentUri) {
    return contentUri.getPath();
}

From source file:Main.java

public static void deleteFile(Uri uri) {
    File f = new File(uri.getPath());
    if (f.exists()) {
        f.delete();//  www .  jav a 2  s. c o  m
    }

}

From source file:Main.java

public static boolean isURIExists(Uri uri) {
    File file = new File(uri.getPath());
    return file.exists();
}

From source file:Main.java

public static File UriToFile(Uri uri) {
    return new File(uri.getPath().replaceFirst("file://", ""));
}

From source file:Main.java

public static String parsePath(Uri uri) {
    return "file://".concat(new File(uri.getPath()).getAbsolutePath());
}

From source file:Main.java

public static BitmapDrawable getBitmapDrawableFromCache(Context context, Uri uri) {
    String path = uri.getPath();
    if (mCache.containsKey(path)) {
        BitmapDrawable d = mCache.get(path).get();
        if (d != null) {
            System.out.println("getBitmapDrawableFromCache path = " + path);
            return d;
        }//from w w  w. ja va2 s .c o m
    }
    return null;
}

From source file:Main.java

public static String getCourseIdentifierFromResumeUri(Uri uri) {

    path = uri.getPath();

    if (path.matches(ROUTE_COURSES + SLASH + ".*")) {

        path = path.replace(ROUTE_COURSES, "").replace(ROUTE_RESUME, "").replace(ROUTE_PINBOARD, "")
                .replace(ROUTE_PROGRESS, "").replace(ROUTE_LEARNING_ROOMS, "").replace(ROUTE_ANNOUNCEMENTS, "")
                .replace(SLASH, "");

        return path;
    }/*w  ww  .  j  a v  a  2 s.c o  m*/

    return path;
}

From source file:Main.java

public static String generateFilePathForVideoSaveWithDraftUri(Uri draftUri) {
    String draftPath = draftUri.getPath();
    String draftMediaDirPath = draftPath.substring(0, draftPath.length() - 5);
    File draftMediaDir = new File(draftMediaDirPath);
    if (!draftMediaDir.exists()) {
        draftMediaDir.mkdirs();/*w  ww.  j a v a 2s .c om*/
    }
    return new File(draftMediaDir, generateRandomFilename("mp4")).getAbsolutePath();
}

From source file:Main.java

public static String prepareFilePathForImageSaveWithDraftUri(Uri draftUri) {
    String draftPath = draftUri.getPath();
    String draftMediaDirPath = draftPath.substring(0, draftPath.length() - 5);
    File draftMediaDir = new File(draftMediaDirPath);
    if (!draftMediaDir.exists()) {
        draftMediaDir.mkdirs();/*from w  w w .j a  va 2  s. c om*/
    }
    return new File(draftMediaDir, generateRandomFilename("jpg")).getAbsolutePath();
}

From source file:Main.java

public static String readTextContent(Uri fileUri) {
    return readTextContent(fileUri.getPath());
}