简体   繁体   中英

Android Preferences List Files

I am trying to make a preferences option that will show the name of all of the files in a specific directory. I have looked, but I haven't seen anything that can do this. Is there a way? Thanks!

William

This

File dir = new File(path_dir); 
File[] files = dir.listFiles();

will get you an array of all the files under path_dir directory. Iterate over it and and append files[i].getName() to an array of CharSequence.

CharSequence[] entries = ...;
ListPreference lp = new ListPreference(this);
lp.setEntries(entries);
lp.setEntryValues(entries);

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