简体   繁体   中英

File.mkdirs warning from Android Studio

in my app I create a new dir in this way;

File mydir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/my_directory");
if (!mydir.exists()) {
    mydir.mkdirs();
}

and it works well, but Android Studio (0.8.9) just continues to report me this warning:

Result of "File.mkdirs()" is ignored

Anyone can explain me why? Thank you.

because you dont do anything with what it returns, you just ignore it

ex.

if(mydir.mkdirs()){
    //do something
}else{
    //do something else
}

you dont need to do anything, its just a warning

You are ignoring result of File.mkdir()

Read this Answer for more clerification

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM