Some tests showed me that in the default directory, where Android stores files created by the application with Context.getFilesDir(), there is/data/data/<your_package_name>/files
To count the files in any directory you use File.listFiles(FileFilter)for the root directory. Your FileFilter should be something like this (to filter ".rbc" files):
public static class RBCFileFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
String suffix = ".rbc";
if( pathname.getName().toLowerCase().endsWith(suffix) ) {
return true;
}
return false;
}
}
If you have some kind of directory structure, you need to search recursively, then you will have File.listFiles(FileFilter)to go through the entire directory structure. And it should be something like:
public static List<File> listFiles(File rootDir, FileFilter filter, boolean recursive) {
List<File> result = new ArrayList<File>();
if( !rootDir.exists() || !rootDir.isDirectory() )
return result;
File[] files = rootDir.listFiles(filter);
for( File f : files) {
if( !result.contains(f) )
result.add(f);
}
if( recursive ) {
File[] dirs = rootDir.listFiles(new DirFilter());
for( File f : dirs ) {
if( f.canRead() ) {
result.addAll(listFiles(f, filter, recursive));
}
}
}
return result;
}
And where it DirFilterwill be implemented FileFilteras follows:
public static class DirFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
if( pathname.isDirectory() )
return true;
return false;
}
}