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

  • SEARCH
  • Home
  • 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 4027328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:05:00+00:00 2026-05-20T11:05:00+00:00

I have the below code which checks to see if folder exists on the

  • 0

I have the below code which checks to see if folder exists on the sdcard, I would like to add another if statement if the folder exists to check that there are zip files inside the actual folder if it in fact exists. What could i do to check the folder for a zip extension. The folder should have a lot of zips in it but i only want it to check to make sure there are zips and no other file extension. I thank you for any help with this.

File z = new File("/mnt/sdcard/folder");
if(!z.exists()) {
Toast.makeText(MainMethod.this, "/sdcard/folder Not Found!", Toast.LENGTH_LONG).show(); 
} else {
Toast.makeText(MainMethod.this, "/sdcard/folder Found!", Toast.LENGTH_LONG).show();
}

EDIT:
Thanks guys for the help here is what i ended up using with your help, i haven’t tested it yet but it looks good to me.

    File z = new File("/mnt/sdcard/Folder");
    if(!z.exists()) {
           //create folder
} else {
        FilenameFilter f2 = new FilenameFilter() {
        public boolean accept(File dir, String filename) {
        return filename.endsWith("zip");
        }
        };
            if (z.list(f2).length > 0) {
            // there's a zip file in there..
            } else {
            //no zips inside folder
        }
    }
  • 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-20T11:05:01+00:00Added an answer on May 20, 2026 at 11:05 am
    File f = new File("folder");
    FilenameFilter f2 = new FilenameFilter() {
    public boolean accept(File dir, String filename) {
    return filename.endsWith("zip");
    }
    };
    if (f.list(f2).length > 0) {
    // there's a zip file in there..
    }
    

    Try the above..

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

Sidebar

Related Questions

I have the below code which checks my dynamically produced offhire boxes to see
I have a code like this below, which gives me a $link that equals
I have the below code, which iterates over a list based on a custom
I have the below code for my a Dialog box for a which contains
I have below is the html code for TD which gets appended after matching
So far i have got the code below which works lovely when trying an
I have the code below, which works fine it can be viewed for an
I have the code below, which sends the value of the textarea and either
EDIT: See my working code in the answers below. In brief: I have a
I have the following PHP code which is attempting to check for password complexity

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.