我通过the solution,
发现了Cursor
此问题
public class MainActivity extends AppCompatActivity {
void example() {
List<File> localAudioFiles = new LinkedList<>();
Uri contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.Images.Media.DATA};
// The problem is that it contains a list of files as of the moment
// when the operating system has been rebooted.
try (Cursor cursor = getContentResolver().query(
contentUri,
projection,
MediaStore.Audio.Media.IS_MUSIC + " != 0",
null,
null);) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
while (cursor.moveToNext()) {
String audio = cursor.getString(column_index);
localAudioFiles.add(new File(audio));
}
} catch (RuntimeException ex) {
}
}
}
但据我了解,其状态需要强制更新,因为在重启设备之前,不会以这种方式检测通过AVD文件管理器添加的文件。
Cursor
的状态?