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 8623507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:17:51+00:00 2026-06-12T07:17:51+00:00

I tried here , but it did not help. My filename filter to get

  • 0

I tried here, but it did not help.

My filename filter to get directories and .txt files only:

FilenameFilter filter = new FilenameFilter()
{
    public boolean accept(File dir, String name)
    {
        if (dir.isDirectory())
        {
            return true;
        }
        else
        {
            return dir.getName().endsWith(".txt");
        }
    }
};

I also tried !dir.isFile()

Applying the filter to the list of files and directories:

            CurDir = homeDir;
            dir = new File(homeDir);
            values = dir.list(filter);
            if (values == null)
            {
                Toast.makeText(this, "No Files/Folders", Toast.LENGTH_LONG).show();
            }
            else
            {
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values);
                setListAdapter(adapter);
            }

Value of homeDir:

homeDir = Environment.getExternalStorageDirectory().toString();

It still shows .png and all other files.

  • 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-06-12T07:17:53+00:00Added an answer on June 12, 2026 at 7:17 am

    The File dir passed is the directory containing the actual file, so it will always be a directory. The full file you have is %dir%/%name%. I believe name will be “/” or perhaps null if the overall file is a directory though.

    You could also create the full file by doing new File(dir, name);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if
I tried searching here , but it couldn't help me much .. I want
I tried looking this up on here but couldnt find a proper answer. I
I've tried the solution here , but it doesn't work. My table is like
I tried a few of the fixes I found here searching around but they
I have looked on here and tried every answer available, but it is still
I tried this JavaScript but it doesn't work - here I need to change
Having an issue here that I have tried everything I can think of but
I tried following some of the code from here and here , but I
I've tried to find answers on MSDN but failed. here is my code: ListView

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.