Android编程实现手机自带内部存储路径的获取方法

2019-12-10 19:53:50王旭
  • File sdCardFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath());  return sdCardFile.getAbsolutePath(); 
  • }  String path = null; 
  • File sdCardFile = null;  ArrayList<String> devMountList = getDevMountList(); 
  • for (String devMount : devMountList) {  File file = new File(devMount); 
  • if (file.isDirectory() && file.canWrite()) {  path = file.getAbsolutePath(); 
  • String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmmss").format(new Date());  File testWritable = new File(path, "test_" + timeStamp); 
  • if (testWritable.mkdirs()) {  testWritable.delete(); 
  • } else {  path = null; 
  • }  } 
  • }  if (path != null) { 
  • sdCardFile = new File(path);  return sdCardFile.getAbsolutePath(); 
  • }  return null; 
  • 希望本文所述对大家Android程序设计有所帮助。


    注:相关教程知识阅读请移步到Android开发频道。