ahmad
11/24/2016 - 9:55 AM

Create Directories on Android SdCard. Simply pass the url as a parameter e.g "/myfolder/newFolder"

Create Directories on Android SdCard. Simply pass the url as a parameter e.g "/myfolder/newFolder"

public void createDirectories(String url) {
		Log.d("DIRECTORY CHECK", "Checking directory " + url + "  exist or not");
		File SDCardRoot = new File(Environment.getExternalStorageDirectory()
				.toString() + url);
		if (!SDCardRoot.exists()) {
			Log.d("DIRECTORY CHECK",
					"Directory doesnt exist creating directory "
							+ Environment.getExternalStorageDirectory()
									.toString());
			boolean outcome = SDCardRoot.mkdirs();

			Log.d("DIRECTORY CHECK",
					"outcome for " + SDCardRoot.getAbsolutePath() + "     "
							+ outcome);
		}

		Log.d("DIRECTORY CHECK", "Directory created successfully!");

	}