当前位置: 首页>>代码示例>>Java>>正文


Java Environment.getStorageState方法代码示例

本文整理汇总了Java中android.os.Environment.getStorageState方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getStorageState方法的具体用法?Java Environment.getStorageState怎么用?Java Environment.getStorageState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Environment的用法示例。


在下文中一共展示了Environment.getStorageState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStorageState

import android.os.Environment; //导入方法依赖的package包/类
private String getStorageState(File path) {
    if(path.getAbsolutePath().startsWith(KernalConstants.baseContext.getFilesDir().getAbsolutePath())){
        return MEDIA_MOUNTED;
    }
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        return Environment.getStorageState(path);
    }

    try {
        final String canonicalPath = path.getCanonicalPath();
        final String canonicalExternal = Environment.getExternalStorageDirectory()
                .getCanonicalPath();

        if (canonicalPath.startsWith(canonicalExternal)) {
            return Environment.getExternalStorageState();
        }
    } catch (IOException e) {
    }

    return MEDIA_UNKNOWN;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:KernalVersionManager.java

示例2: getStorageState

import android.os.Environment; //导入方法依赖的package包/类
public static String getStorageState(File path) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        return Environment.getStorageState(path);
    }

    try {
        final String canonicalPath = path.getCanonicalPath();
        final String canonicalExternal = Environment.getExternalStorageDirectory()
                .getCanonicalPath();

        if (canonicalPath.startsWith(canonicalExternal)) {
            return Environment.getExternalStorageState();
        }
    } catch (IOException e) {
    }

    return MEDIA_UNKNOWN;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:20,代码来源:Framework.java

示例3: updateVolumesLocked

import android.os.Environment; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private void updateVolumesLocked() {
    mRoots.clear();
    mIdToPath.clear();
    mIdToRoot.clear();
    
    int count = 0;
    StorageUtils storageUtils = new StorageUtils(getContext());
    for (StorageVolume volume : storageUtils.getStorageMounts()) {
        final File path = volume.getPathFile();
        if(Utils.hasKitKat()){
     	String state = Environment.getStorageState(path);
         final boolean mounted = Environment.MEDIA_MOUNTED.equals(state)
                 || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
         if (!mounted) continue;
        }
        final String rootId;
        if (volume.isPrimary() && volume.isEmulated()) {
            rootId = ROOT_ID_PRIMARY_EMULATED;
        } else if (volume.getUuid() != null) {
            rootId = ROOT_ID_SECONDARY + volume.getUserLabel();
        } else {
            Log.d(TAG, "Missing UUID for " + volume.getPath() + "; skipping");
            continue;
        }

        if (mIdToPath.containsKey(rootId)) {
            Log.w(TAG, "Duplicate UUID " + rootId + "; skipping");
            continue;
        }

        try {
        	if(null == path.listFiles()){
        		continue;
        	}
            mIdToPath.put(rootId, path);
            final RootInfo root = new RootInfo();
            
            root.rootId = rootId;
            root.flags = Document.FLAG_SUPPORTS_THUMBNAIL;
            if (ROOT_ID_PRIMARY_EMULATED.equals(rootId)) {
                root.title = getContext().getString(R.string.root_internal_storage);
            } else {
            	count++;
                root.title = getContext().getString(R.string.root_external_storage) + " " + count;// + volume.getLabel();
            }
            root.docId = getDocIdForFile(path);
            mRoots.add(root);
            mIdToRoot.put(rootId, root);
        } catch (FileNotFoundException e) {
            throw new IllegalStateException(e);
        }
    }

    Log.d(TAG, "After updating volumes, found " + mRoots.size() + " active roots");

    getContext().getContentResolver()
            .notifyChange(DocumentsContract.buildRootsUri(AUTHORITY), null, false);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:60,代码来源:HeatMapProvider.java

示例4: getStorageState

import android.os.Environment; //导入方法依赖的package包/类
public static String getStorageState(File path) {
    return Environment.getStorageState(path);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:EnvironmentCompatKitKat.java


注:本文中的android.os.Environment.getStorageState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。