Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of files from a specific folder in internal storage?

Tags:

file

android

With listFiles() I can get list of file in /data/data/package/files.
How can I get list of files from directory like /data/data/package/myfolder ?

Thanks.

like image 306
Rami Avatar asked Aug 08 '12 19:08

Rami


1 Answers

Your application has a "Files" and "Caches" directory. You can query this path with Context.getFilesDir() or Context.getCacheDir().

There is also a Context.getDir() function for private folders like "myfolder".

With the corrsponding File object, you can enumerate the files.

File dirFiles = mContext.getFilesDir();
for (String strFile : dirFiles.list())
{
 // strFile is the file name
}
like image 160
CSmith Avatar answered Sep 19 '22 14:09

CSmith