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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:51:43+00:00 2026-05-24T10:51:43+00:00

I am writing an Android mediaPlayer app, so I want to scan through all

  • 0

I am writing an Android mediaPlayer app, so I want to scan through all files on the entire phone (i.e. sdcard and phone memory). I can read from the sdcard, but not the root of it. That is, I can just read from the path /sdcard/[folder]/ and it works fine, but if I go to /sdcard/ the app crashes. How can I access all the files on the sdcard, as well as the files on the phone itself?

  • 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-24T10:51:44+00:00Added an answer on May 24, 2026 at 10:51 am

    Never use the /sdcard/ path. it is not guaranteed to work all the time.

    Use below code to get the path to sdcard directory.

    File root = Environment.getExternalStorageDirectory();
    String rootPath= root.getPath();
    

    From rootPath location, you can build the path to any file on the SD Card. For example if there is an image at /DCIM/Camera/a.jpg, then absolute path would be rootPath + “/DCIM/Camera/a.jpg”.

    However to list all files in the SDCard, you can use the below code

    String listOfFileNames[] = root.list(YOUR_FILTER);
    

    listOfFileNames will have names of all the files that are present in the SD Card and pass the criteria set by filter.

    Suppose you want to list mp3 files only, then pass the below filter class name to list() function.

    FilenameFilter mp3Filter = new FilenameFilter() {
    File f;
        public boolean accept(File dir, String name) {
    
            if(name.endsWith(".mp3")){
            return true;
            }
    
            f = new File(dir.getAbsolutePath()+"/"+name);
    
            return f.isDirectory();
        }
    };
    

    Shash

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

Sidebar

Related Questions

I'm writing an android app and I need to read several files from several
I am part way through writing a media player app for Android. It's all
I am writing android app that makes AES encryption/decryption of files. I want to
I'm writing an Android app where users can upload video to Youtube. I'd like
I am writing an android app. I want to pass some data across the
I'm writing an Android email client app, based on the Javamail API. I can
I'm writing an Android app in Eclipse that uses the OpenCV4Android API. How can
I'm writing an android application, which user can download some image files from server.
I'm writing an Android app that I want to use in conjunction with a
I am writing an android app and testing in on my own phone. It's

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.