Check if directory exist on android's sdcard

前端 未结 6 720
时光说笑
时光说笑 2020-12-24 05:01

How do I check if a directory exist on the sdcard in android?

6条回答
  •  Happy的楠姐
    2020-12-24 05:25

    Yup tried a lot, beneath code helps me :)

     File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "ur directory name");
    
                    if (!folder.exists()) {
                        Log.e("Not Found Dir", "Not Found Dir  ");
                    } else {
                        Log.e("Found Dir", "Found Dir  " );
                       Toast.makeText(getApplicationContext(),"Directory is already exist" ,Toast.LENGTH_SHORT).show();
                    }

提交回复
热议问题