Home > Mobile >  For help ~ ~ why returns null listFiles dynamic permissions have
For help ~ ~ why returns null listFiles dynamic permissions have

Time:01-05

Attach a part of the source
//list to add MP3 name
Private void setListViewAdapter () {
List MusicList=new ArrayList<> (a);
Try {
The File PATH=Environment. External.getexternalstoragedirectory ();//to get SD card total directory,
The File MUSIC_PATH=new File (PATH, "Music");//get the root directory of the secondary directory Music
If (MUSIC_PATH listFiles (new MusicService MusicFilter ()). The length & gt; 0 {
For (the File File: MUSIC_PATH. ListFiles (new MusicService. MusicFilter ())) {
MusicList. Add (file. GetAbsolutePath ());
}
} else {Log i. (" ZWZWZW ", "BBBB"); }
} the catch (Exception e) {
e.printStackTrace();
}

This is abnormal
The 2021-01-03 22:29:26. 156, 17494-17494/com. Example. Bofangqi_zw W/System. Err: Java. Lang. NullPointerException: Attempt to get the length of null array

CodePudding user response:

Check the permission of the sd with problems

CodePudding user response:

https://blog.csdn.net/mozushixin_1/article/details/89332477
  • Related