William Hoskins
William Hoskins

Reputation: 305

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

Upvotes: 1

Views: 348

Answers (1)

nullpotent
nullpotent

Reputation: 9260

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);

Upvotes: 4

Related Questions