views:

257

answers:

1

Hello! I would like to store only .txt filenames from a specific dir (let's say: /sdcard/docs/) into an String array.

Example: In /sdcard/docs/ there are 5 files: 'foo.txt', 'bar.jpg', 'foofoo.txt', 'loool.png' and 'foobar.txt'. I would like to get array with contents: "foo.txt", "foofoo.txt", "foobar.txt"

How could I do it? Thanks =)

A: 

List all files:

http://developer.android.com/intl/zh-CN/reference/java/io/File.html#list%28%29

or

List with filter:

http://developer.android.com/intl/zh-CN/reference/java/io/File.html#list%28java.io.FilenameFilter%29

Just pass your path to the File constructor, and call one of the above methods on it.

Rich
Thanks for help!
JustMe