com.blankj.utilcode.util.SDCardUtils Java Examples
The following examples show how to use
com.blankj.utilcode.util.SDCardUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSaveUtils.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
/** * 系统保存文件目录 * @param name 自己命名 * @return 路径 */ public static String getLocalRootSavePathDir(String name){ if(TextUtils.isEmpty(name)){ return ""; } //获得SDCard 的路径,storage/sdcard String sdPath = SDUtils.getSDCardPath(); //判断 SD 卡是否可用 if (!SDCardUtils.isSDCardEnable() || TextUtils.isEmpty(sdPath)) { //获取 SD 卡路径 List<String> sdPathList = SDCardUtils.getSDCardPaths(); if (sdPathList != null && sdPathList.size() > 0 && !TextUtils.isEmpty(sdPathList.get(0))) { sdPath = sdPathList.get(0); } } if (TextUtils.isEmpty(sdPath)) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(sdPath); sb.append(property); sb.append(APP_ROOT_SAVE_PATH); sb.append(property); sb.append(name); sb.append(property); return sb.toString(); }
Example #2
Source File: SDCardActivity.java From Android-UtilCode with Apache License 2.0 | 5 votes |
@Override public void initView(Bundle savedInstanceState, View view) { TextView tvAboutSdcard = (TextView) findViewById(R.id.tv_about_sdcard); tvAboutSdcard.setText("isSDCardEnable: " + SDCardUtils.isSDCardEnable() + "\ngetDataPath: " + SDCardUtils.getDataPath() + "\ngetSDCardPath: " + SDCardUtils.getSDCardPath() + "\ngetFreeSpace: " + SDCardUtils.getFreeSpace() + "\ngetSDCardInfo: " + SDCardUtils.getSDCardInfo() ); }
Example #3
Source File: FileItem.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
private static List<FileItem> getFileItems() { List<FileItem> fileItems = new ArrayList<>(); String internalAppDataPath = PathUtils.getInternalAppDataPath(); if (!StringUtils.isEmpty(internalAppDataPath)) { File internalDataFile = new File(internalAppDataPath); if (internalDataFile.exists()) { fileItems.add(new FileItem(internalDataFile, "internal")); } } String externalAppDataPath = PathUtils.getExternalAppDataPath(); if (!StringUtils.isEmpty(externalAppDataPath)) { File externalDataFile = new File(externalAppDataPath); if (externalDataFile.exists()) { fileItems.add(new FileItem(externalDataFile, "external")); } } List<String> mountedSDCardPath = SDCardUtils.getMountedSDCardPath(); if (!mountedSDCardPath.isEmpty()) { for (int i = 0; i < mountedSDCardPath.size(); i++) { String path = mountedSDCardPath.get(i); File sdPath = new File(path); if (sdPath.exists()) { fileItems.add(new FileItem(sdPath, "sdcard" + i + "_" + sdPath.getName(), true)); } } } return fileItems; }