android路径获取

//内部路径

Environment.getDataDirectory()=/data

Environment.getDownloadCacheDirectory()=/cache

Environment.getRootDirectory()=/system

context.getCacheDir()=/data/data/com.penngo.test/cache

context.getFilesDir()=/data/data/com.penngo.test/files


// 存储卡路径

Environment.getExternalStorageDirectory()=/storage/sdcard0


// 可选值DIRECTORY_MUSIC, DIRECTORY_PODCASTS, DIRECTORY_RINGTONES, 

// DIRECTORY_ALARMS, DIRECTORY_NOTIFICATIONS, DIRECTORY_PICTURES, 

// DIRECTORY_MOVIES, DIRECTORY_DOWNLOADS, or DIRECTORY_DCIM. 不能为null

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC)=/storage/sdcard0/Music


// 与context.getFilesDir(相似,删除应用时会同时删除

context.getExternalFilesDir()=/storage/sdcard0/Android/data/com.penngo.test/files

// 与context.getCacheDir()相似,删除应用时会同时删除

context.getExternalCacheDir()=/storage/sdcard0/Android/data/com.penngo.test/cache


System.getProperty("user.home")=

System.getProperty("java.io.tmpdir")=/data/data/com.penngo.test/cache

new File().getAbsolutePath()=/.



//判断存储卡是否存在

public static boolean isSdCardExist() {

  if (Environment.getExternalStorageState().equals(

    Environment.MEDIA_MOUNTED)) {//判断是否已经挂载

   return true;

  }

  return false;

 }


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。