检查目录末尾?

时间:2011-10-19 07:07:16

标签: android directory

我正在尝试为用户提供一个简单的文件浏览器,以便为我的应用程序选择一个首选项。有没有办法检查/检测目录的结尾?

2 个答案:

答案 0 :(得分:0)

你的意思是说CWD中是否没有子目录?

File[] dirs = currentWorkingDir.listFiles();
boolean noDirs = true;
 for(File ff: dirs)
{
   if(ff.isDirectory())
   {   noDirs = false;    break; }

}

如果noDirs == true没有子目录

答案 1 :(得分:0)

String path="/sdcard/any directory name/";
    file=new File(path); 
//check directory is exists
    if(!file.exists())
    {
  //if not exists then create new directory

      boolean success = (
                  new File(path)).mkdir();
    }