android.os.Environment.getDownloadCacheDirectory()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(293)

本文整理了Java中android.os.Environment.getDownloadCacheDirectory()方法的一些代码示例,展示了Environment.getDownloadCacheDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getDownloadCacheDirectory()方法的具体详情如下:
包路径:android.os.Environment
类名称:Environment
方法名:getDownloadCacheDirectory

Environment.getDownloadCacheDirectory介绍

暂无

代码示例

代码示例来源:origin: lingochamp/FileDownloader

  1. public static String getDefaultSaveRootPath() {
  2. if (!TextUtils.isEmpty(defaultSaveRootPath)) {
  3. return defaultSaveRootPath;
  4. }
  5. if (FileDownloadHelper.getAppContext().getExternalCacheDir() == null) {
  6. return Environment.getDownloadCacheDirectory().getAbsolutePath();
  7. } else {
  8. //noinspection ConstantConditions
  9. return FileDownloadHelper.getAppContext().getExternalCacheDir().getAbsolutePath();
  10. }
  11. }

代码示例来源:origin: lingochamp/okdownload

  1. public static String getDefaultSaveRootPath() {
  2. if (!TextUtils.isEmpty(defaultSaveRootPath)) {
  3. return defaultSaveRootPath;
  4. }
  5. if (FileDownloadHelper.getAppContext().getExternalCacheDir() == null) {
  6. return Environment.getDownloadCacheDirectory().getAbsolutePath();
  7. } else {
  8. //noinspection ConstantConditions
  9. return FileDownloadHelper.getAppContext().getExternalCacheDir().getAbsolutePath();
  10. }
  11. }

代码示例来源:origin: huangfangyi/FanXin

  1. /**
  2. * 获取APP文件目录下的cache文件家
  3. * @return
  4. */
  5. private String getDefaultSaveRootPath(Context applicion) {
  6. if (applicion.getExternalCacheDir() == null) {
  7. return Environment.getDownloadCacheDirectory().getAbsolutePath();
  8. } else {
  9. //noinspection ConstantConditions
  10. return applicion.getExternalCacheDir().getAbsolutePath();
  11. }
  12. }
  13. private void printLog(String tag ,String logMessage){

代码示例来源:origin: 80945540/FreeBook

  1. public String patch(String flie) {
  2. if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
  3. //取得SD卡文件路径
  4. return Environment.getExternalStorageDirectory().getAbsolutePath() + "/freeBookDownload/"+flie;
  5. }else{
  6. return Environment.getDownloadCacheDirectory().getAbsolutePath() + "/freeBookDownload/"+flie;
  7. }
  8. }
  9. }

代码示例来源:origin: Over17/UnityOBBDownloader

  1. /**
  2. * Checks whether the filename looks legitimate
  3. */
  4. public static boolean isFilenameValid(String filename) {
  5. filename = filename.replaceFirst("/+", "/"); // normalize leading
  6. // slashes
  7. return filename.startsWith(Environment.getDownloadCacheDirectory().toString())
  8. || filename.startsWith(Environment.getExternalStorageDirectory().toString());
  9. }

代码示例来源:origin: xujianhui404/livewallpaper

  1. public static String getCacheDir() {
  2. String path;
  3. if (Environment.getExternalStorageState().equals(Environment.MEDIA_UNMOUNTED)) {
  4. path = Environment.getDownloadCacheDirectory().getAbsolutePath();
  5. } else {
  6. path = Environment.getExternalStorageDirectory().getAbsolutePath();
  7. }
  8. return path;
  9. }

代码示例来源:origin: dengshiwei/AndroidUtils

  1. /**
  2. * 获取SD卡DownloadCache路径
  3. * @return
  4. * SD卡存在返回正常路径;SD卡不存在返回""
  5. */
  6. public static String getSDCardDownloadCachePath(){
  7. if(isSDCardEnable()){
  8. return Environment.getDownloadCacheDirectory().getAbsolutePath() + File.separator;
  9. }else{
  10. return "";
  11. }
  12. }

代码示例来源:origin: Over17/UnityOBBDownloader

  1. /**
  2. * @return the root of the filesystem containing the given path
  3. */
  4. public static File getFilesystemRoot(String path) {
  5. File cache = Environment.getDownloadCacheDirectory();
  6. if (path.startsWith(cache.getPath())) {
  7. return cache;
  8. }
  9. File external = Environment.getExternalStorageDirectory();
  10. if (path.startsWith(external.getPath())) {
  11. return external;
  12. }
  13. throw new IllegalArgumentException(
  14. "Cannot determine filesystem root for " + path);
  15. }

代码示例来源:origin: 0xm1nam0/RxCore

  1. public static String getCachePath(String cachePath) {
  2. if (!isSDCardEnable()) return Environment.getDownloadCacheDirectory().getPath() + File.separator + cachePath + File.separator;;
  3. return Environment.getExternalStorageDirectory().getPath() + File.separator + cachePath + File.separator;
  4. }
  5. /**

代码示例来源:origin: dengshiwei/AndroidUtils

  1. /**
  2. * 获取SD卡DownloadCache路径
  3. * @return
  4. * SD卡存在返回正常路径;SD卡不存在返回null
  5. */
  6. public static File getSDCardDownloadCacheFile(){
  7. if(isSDCardEnable()){
  8. return Environment.getDownloadCacheDirectory();
  9. }else{
  10. return null;
  11. }
  12. }

代码示例来源:origin: wangli135/BlogDemo

  1. sb.append("DownloadCacheDirectory:" + Environment.getDownloadCacheDirectory().getAbsolutePath() + "\n");
  2. sb.append("ExternalStorageDirectory():" + Environment.getExternalStorageDirectory().getAbsolutePath() + "\n");
  3. sb.append("ExternalStoragePublicDirectory:" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath() + "\n");

代码示例来源:origin: gigabytedevelopers/FireFiles

  1. public long getPartionSize(int type, boolean isTotal){
  2. Long size = 0L;
  3. switch (type) {
  4. case PARTITION_SYSTEM:
  5. size = getPartionSize(Environment.getRootDirectory().getPath(), isTotal);
  6. break;
  7. case PARTITION_DATA:
  8. size = getPartionSize(Environment.getDataDirectory().getPath(), isTotal);
  9. break;
  10. case PARTITION_CACHE:
  11. size = getPartionSize(Environment.getDownloadCacheDirectory().getPath(), isTotal);
  12. break;
  13. case PARTITION_EXTERNAL:
  14. size = getPartionSize(Environment.getExternalStorageDirectory().getPath(), isTotal);
  15. break;
  16. /*case PARTITION_EMMC:
  17. size = getPartionSize(DIR_EMMC, isTotal);
  18. break;*/
  19. case PARTITION_RAM:
  20. size = getSizeTotalRAM(isTotal);
  21. break;
  22. }
  23. return size;
  24. }

相关文章