@Test @SuppressWarnings("PMD.DoNotHardCodeSDCard") public void simplifyScopedStoragePathTest() { assertThat(FileUtils.simplifyScopedStoragePath(null), is(nullValue())); assertThat(FileUtils.simplifyScopedStoragePath(""), is("")); assertThat(FileUtils.simplifyScopedStoragePath("blahblahblah"), is("blahblahblah")); assertThat(FileUtils.simplifyScopedStoragePath("/storage/emulated/0/Android/data/org.odk.collect.android/files/layers"), is("/sdcard/Android/data/org.odk.collect.android/files/layers")); assertThat(FileUtils.simplifyScopedStoragePath("/storage/emulated/0/Android/data/org.odk.collect.android/files/layers/countries/countries-raster.mbtiles"), is("/sdcard/Android/data/org.odk.collect.android/files/layers/countries/countries-raster.mbtiles")); }
@SuppressWarnings("PMD.DoNotHardCodeSDCard") public static String simplifyScopedStoragePath(String path) { if (path != null && path.startsWith("/storage/emulated/0/")) { return "/sdcard/" + path.substring("/storage/emulated/0/".length()); } return path; }
FileUtils { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public static String simplifyScopedStoragePath(String path) { if (path != null && path.startsWith("/storage/emulated/0/")) { return "/sdcard/" + path.substring("/storage/emulated/0/".length()); } return path; } }
FileUtils { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public static String simplifyScopedStoragePath(String path) { if (path != null && path.startsWith("/storage/emulated/0/")) { return "/sdcard/" + path.substring("/storage/emulated/0/".length()); } return path; } private  FileUtils(); }
FileUtils { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public static String simplifyScopedStoragePath(String path) { if (path != null && path.startsWith("/storage/emulated/0/")) { return "/sdcard/" + path.substring("/storage/emulated/0/".length()); } return path; } private  FileUtils(); static String getMimeType(String fileUrl); static boolean createFolder(String path); static String getMd5Hash(File file); static String getMd5Hash(InputStream is); static Bitmap getBitmapScaledToDisplay(File file, int screenHeight, int screenWidth); static Bitmap getBitmapScaledToDisplay(File file, int screenHeight, int screenWidth, boolean upscaleEnabled); static String copyFile(File sourceFile, File destFile); static HashMap<String, String> getMetadataFromFormDefinition(File formDefinitionXml); static void deleteAndReport(File file); static String getFormBasename(File formXml); static String getFormBasename(String formFilePath); static String constructMediaPath(String formFilePath); static File getFormMediaDir(File formXml); static String getFormBasenameFromMediaFolder(File mediaFolder); static File getLastSavedFile(File formXml); static String getLastSavedPath(File mediaFolder); static String getOrCreateLastSavedSrc(File formXml); static void checkMediaPath(File mediaDir); static void purgeMediaPath(String mediaPath); static void moveMediaFiles(String tempMediaPath, File formMediaPath); static void saveBitmapToFile(Bitmap bitmap, String path); static Bitmap getBitmap(String path, BitmapFactory.Options originalOptions); static byte[] read(File file); static void write(File file, byte[] data); static int comparePaths(String a, String b); static String getFileExtension(String fileName); static void grantFilePermissions(Intent intent, Uri uri, Context context); static void grantFileReadPermissions(Intent intent, Uri uri, Context context); @SuppressWarnings("PMD.DoNotHardCodeSDCard") static String simplifyPath(File file); @SuppressWarnings("PMD.DoNotHardCodeSDCard") static String simplifyScopedStoragePath(String path); static Iterable<File> walk(File root); static Iterable<File> walkBreadthFirst(File root); }
FileUtils { @SuppressWarnings("PMD.DoNotHardCodeSDCard") public static String simplifyScopedStoragePath(String path) { if (path != null && path.startsWith("/storage/emulated/0/")) { return "/sdcard/" + path.substring("/storage/emulated/0/".length()); } return path; } private  FileUtils(); static String getMimeType(String fileUrl); static boolean createFolder(String path); static String getMd5Hash(File file); static String getMd5Hash(InputStream is); static Bitmap getBitmapScaledToDisplay(File file, int screenHeight, int screenWidth); static Bitmap getBitmapScaledToDisplay(File file, int screenHeight, int screenWidth, boolean upscaleEnabled); static String copyFile(File sourceFile, File destFile); static HashMap<String, String> getMetadataFromFormDefinition(File formDefinitionXml); static void deleteAndReport(File file); static String getFormBasename(File formXml); static String getFormBasename(String formFilePath); static String constructMediaPath(String formFilePath); static File getFormMediaDir(File formXml); static String getFormBasenameFromMediaFolder(File mediaFolder); static File getLastSavedFile(File formXml); static String getLastSavedPath(File mediaFolder); static String getOrCreateLastSavedSrc(File formXml); static void checkMediaPath(File mediaDir); static void purgeMediaPath(String mediaPath); static void moveMediaFiles(String tempMediaPath, File formMediaPath); static void saveBitmapToFile(Bitmap bitmap, String path); static Bitmap getBitmap(String path, BitmapFactory.Options originalOptions); static byte[] read(File file); static void write(File file, byte[] data); static int comparePaths(String a, String b); static String getFileExtension(String fileName); static void grantFilePermissions(Intent intent, Uri uri, Context context); static void grantFileReadPermissions(Intent intent, Uri uri, Context context); @SuppressWarnings("PMD.DoNotHardCodeSDCard") static String simplifyPath(File file); @SuppressWarnings("PMD.DoNotHardCodeSDCard") static String simplifyScopedStoragePath(String path); static Iterable<File> walk(File root); static Iterable<File> walkBreadthFirst(File root); static final String VALID_FILENAME; static final String FORMID; static final String VERSION; static final String TITLE; static final String SUBMISSIONURI; static final String BASE64_RSA_PUBLIC_KEY; static final String AUTO_DELETE; static final String AUTO_SEND; static final String GEOMETRY_XPATH; static final String MEDIA_SUFFIX; static final String LAST_SAVED_FILENAME; static final String STUB_XML; }