Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4016742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:46:38+00:00 2026-05-20T09:46:38+00:00

In the app I’m developing for Android I’m letting users create files specific to

  • 0

In the app I’m developing for Android I’m letting users create files specific to my application with the extension “.rbc”. So far I have been successful in creating, writing to, and reading from these files.

Right now I am trying to count the number of these files that exists. I’m not particularly familiar with Java and I’m just beginning programming for Android so I feel a bit lost. All of my attempts so far at doing this have not been able to locate any files with my extension.

So I basically have two questions I need answered so that I can figure this out:

Where is the default directory where Android stores files created by an application?

Do you have any examples do you can give me of counting files with a specific extension on Android?

Thank you very much in advance for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:46:38+00:00Added an answer on May 20, 2026 at 9:46 am

    Some tests showed me that the default directory where Android stores files created by an application using Context.getFilesDir() is /data/data/<your_package_name>/files

    To count the files in any given directory you use File.listFiles(FileFilter) over the root dir. Your FileFilter should then be something like this (to filter for “.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 recursively search then you will have to File.listFiles(FileFilter) over 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;
    
    
        //Add all files that comply with the given filter
        File[] files = rootDir.listFiles(filter);
        for( File f : files) {
            if( !result.contains(f) )
                result.add(f);
        }
    
        //Recurse through all available dirs if we are scanning recursively
        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 DirFilter would implements FileFilter this way:

    public static class DirFilter implements FileFilter {
    
        @Override
        public boolean accept(File pathname) {
            if( pathname.isDirectory() ) 
                return true;
    
            return false;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new web app that is packaged as a WAR as part
I'm trying to write test harness for part of my Android mapping application. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.