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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:55:26+00:00 2026-06-17T14:55:26+00:00

In my app i am getting the images from a folder in gallery and

  • 0

In my app i am getting the images from a folder in gallery and saving it into an array list.Now i want to extract only the files with .jpg extension.How can i do it

The code for saving to array list is

  private List<String> ReadSDCard()
    {
     //It have to be matched with the directory in SDCard
     File f = new File("sdcard/data/crak");

     File[] files=f.listFiles();

     for(int i=0; i<files.length; i++)
     {
      File file = files[i];
      /*It's assumed that all file in the path are in supported type*/
      tFileList.add(file.getPath());
     }
     return tFileList;
    }
  • 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-17T14:55:28+00:00Added an answer on June 17, 2026 at 2:55 pm

    Use .endsWith() method from Java String Class to check File Extension from file path.

    Method:

    public boolean endsWith(String suffix)
    

    Your Code something like,

    private List<String> ReadSDCard()
    {
         //It have to be matched with the directory in SDCard
         File f = new File("sdcard/data/crak");
    
         File[] files=f.listFiles();
    
         for(int i=0; i<files.length; i++)
         {
          File file = files[i];
          /*It's assumed that all file in the path are in supported type*/
          String filePath = file.getPath();
          if(filePath.endsWith(".jpg")) // Condition to check .jpg file extension
          tFileList.add(filePath);
         }
     return tFileList;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to preview images and other files from the app's documents folder. I
In my Iphone app.i'm not getting the images in imageview.Those images are coming from
I'm trying to load images from Flickr's API into a Ruby on Rails app,
I'm developing a small gallery application, in this application im getting images from sdcard
I have a GUI app that is getting to be quite slow. I want
So, my list of models in app/models is getting kinda long, and I'd like
I have an ipad app which takes images from Photos application using ALAssetsLibrary and
We are working on an native Android app that handles large images (5MP+) from
I'm working on a project which is saving some images to sdcard and now
I am grabbing images from the users' contacts in their iOS Address Book/Contacts.app. And

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.