List of usage examples for android.os Environment getRootDirectory
public static File getRootDirectory()
From source file:Main.java
public static String getRootDirectoryPath() { return Environment.getRootDirectory().getAbsolutePath(); }
From source file:Main.java
public static String getMobileMemoryPath() { return Environment.getRootDirectory().getPath(); }
From source file:Main.java
public static File getSDCardRootFile() { if (isSDCardEnable()) { return Environment.getRootDirectory(); } else {//w w w. j a va 2s .c o m return null; } }
From source file:Main.java
public static boolean isInternal(String path) { return TextUtils.isEmpty(path) || path.startsWith(Environment.getRootDirectory() + "/media") || path.startsWith(getDataSDCardRoot()); }
From source file:Main.java
public static String getSDPath() { File sdDir = null;//from ww w. java 2 s . c o m boolean sdCardExist = Environment.getExternalStorageState().equals("mounted"); if (sdCardExist) { sdDir = Environment.getExternalStorageDirectory(); } else { sdDir = Environment.getRootDirectory(); } return sdDir.toString(); }
From source file:com.adhi.quantumthemer.aFileChooser.FileListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new FileListAdapter(getActivity()); mPath = getArguments() != null ? getArguments().getString(FileChooserActivity.PATH) : Environment.getExternalStorageDirectory().getAbsolutePath(); if (FileChooserActivity.rBrowseRoot) { mPath = getArguments() != null ? getArguments().getString(FileChooserActivity.PATH) : Environment.getRootDirectory().getAbsolutePath(); }/*from w w w . j av a 2 s. co m*/ }
From source file:net.sf.fakenames.fddemo.BaseDirLayout.java
public void init() throws IOException { home = getBaseDir();/*from w w w . j av a 2 s . c o m*/ mountInfo = MountsSingleton.get(os); final HashMap<File, String> pathNameMap = new HashMap<>(); File systemRoot = Environment.getRootDirectory(); try { systemRoot = systemRoot.getCanonicalFile(); } catch (IOException ignore) { // ok } pathNameMap.put(systemRoot, "Android system root"); File filesDir = getFilesDir(); try { filesDir = filesDir.getCanonicalFile(); } catch (IOException ignore) { // ok } pathNameMap.put(filesDir, "Internal private storage"); File[] external = ContextCompat.getExternalFilesDirs(this, null); for (int i = 0; i < external.length; ++i) { File resolved = external[i]; if (resolved == null) continue; try { resolved = resolved.getCanonicalFile(); } catch (IOException ignore) { // ok } pathNameMap.put(resolved, "External storage " + i); } List<StorageVolume> volumes = new ArrayList<>(); if (Build.VERSION.SDK_INT >= 24) { final StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE); volumes.addAll(sm.getStorageVolumes()); } final Lock lock = mountInfo.getLock(); lock.lock(); try { parseMounts(pathNameMap, volumes); } finally { lock.unlock(); } }
From source file:de.k3b.android.toGoZip.SettingsImpl.java
/** * calculates the dafault-path value for 2go.zip *//*from ww w .j av a2 s . com*/ public static String getDefaultZipDirPath(Context context) { File rootDir = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { // before api-14/android-4.4/KITKAT // write support on sdcard, if mounted Boolean isSDPresent = Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); rootDir = ((isSDPresent)) ? Environment.getExternalStorageDirectory() : Environment.getRootDirectory(); } else if (Global.USE_DOCUMENT_PROVIDER && (zipDocDirUri != null)) { // DocumentFile docDir = DocumentFile.fromTreeUri(context, Uri.parse(zipDocDirUri)); DocumentFile docDir = DocumentFile.fromFile(new File(zipDocDirUri)); if ((docDir != null) && docDir.canWrite()) { return rootDir.getAbsolutePath(); } } if (rootDir == null) { // since android 4.4 Environment.getDataDirectory() and .getDownloadCacheDirectory () // is protected by android-os :-( rootDir = getRootDir44(); } final String zipfile = rootDir.getAbsolutePath() + "/copy"; return zipfile; }
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesStorage.java
private void initStorageList() { mStorageList.clear();//ww w. j av a 2 s .c o m mStorageCount = 0; StorageUnit unit = new StorageUnit(mStorageCount, "Internal", "fixed"); unit.setPath(Environment.getRootDirectory().getAbsolutePath()); mStorageList.put(mStorageCount, unit); ++mStorageCount; // Attempt to add emulated stroage first int sdcardNum = mStorageCount - 1; // sdcard count from 0 unit = new StorageUnit(mStorageCount, new String("sdcard" + Integer.toString(sdcardNum)), "fixed"); if (Environment.isExternalStorageRemovable()) { unit.setType("removable"); } unit.setPath(Environment.getExternalStorageDirectory().getAbsolutePath()); if (unit.isValid()) { mStorageList.put(mStorageCount, unit); ++mStorageCount; } // Then attempt to add real removable storage attemptAddExternalStorage(); }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device disk space. *//*from w ww . j av a2s . co m*/ static String getDiskCurrent() { if (android.os.Build.VERSION.SDK_INT < 18) { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCount() * statFs.getBlockSize()); long free = (statFs.getAvailableBlocks() * statFs.getBlockSize()); return Long.toString((total - free) / 1048576L); } else { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCountLong() * statFs.getBlockSizeLong()); long free = (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong()); return Long.toString((total - free) / 1048576L); } }