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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:50:46+00:00 2026-05-23T18:50:46+00:00

I want to show an images gallery . The problem is during the loading

  • 0

I want to show an images gallery. The problem is during the loading of them.

At the beginning, I was loading the images with :

images = new File("/sdcard/DCIM/Camera/");
if(images.listFiles().length==0)
   //no images, do some other stuff...
else
   //put images in the gallery and do some stuff

This code works with the emulator (Android 2.2 – API Level 8) and with a Samsung Galaxy S2 (Android 2.2.1). But I ask some friends to test this code with their own phones (HTC, LG…).

With an HTC Desire, there is a problem during this loading. The code is going into “//no images” but they have images in the album (for example from Camera…) My friend said to me that :

album is stored in the internal storage and not in the SD Card with HTC.

So i’ve tried to check others directory, like this :

//Get the internal content
images = new File(MediaStore.Images.Media.INTERNAL_CONTENT_URI.getPath());

if (!images.isDirectory()) {
    //Get the external content
    images = new File(MediaStore.Images.Media.EXTERNAL_CONTENT_URI.getPath());
}

if (!images.isDirectory()) {
    //Get the SD Card content
    images = new File("/sdcard/DCIM/Camera/");
}

But still not working 🙁 That is not the good directory :/

So, my question is : how can i get the good path for images with all android phone ? is their an Object which is able to return the path of the album ?

Thanks 🙂

(sorry for mistakes)

  • 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-23T18:50:47+00:00Added an answer on May 23, 2026 at 6:50 pm

    I did some checking and it looks like you are trying to access the MediaStore incorrectly. It should be accessed via a cursor and not directly as a file.

    This is because as mentioned at http://developer.android.com/guide/topics/providers/content-providers.html

    Content providers expose their data as a simple table on a database model, where each row is a record and each column is data of a particular type and meaning.

    So basically you can’t read the URI as a file. It is a table of data.

    Here’s an example from that same page on how to access it.

    import android.provider.Contacts.People;
    import android.content.ContentUris;
    import android.net.Uri;
    import android.database.Cursor;
    
    // Use the ContentUris method to produce the base URI for the contact with _ID == 23.
    Uri myPerson = ContentUris.withAppendedId(People.CONTENT_URI, 23);
    
    // Alternatively, use the Uri method to produce the base URI.
    // It takes a string rather than an integer.
    Uri myPerson = Uri.withAppendedPath(People.CONTENT_URI, "23");
    
    // Then query for this specific record:
    Cursor cur = managedQuery(myPerson, null, null, null, null);
    

    Also, here’s another Stackoverflow question that has some examples that shows how to use the cursor.

    How to query Android MediaStore Content Provider, avoiding orphaned images?

    Finally, based on the links above I would just use the mediastore object as a cursor on all devices and that will solve the problem you are having with different directories.

    Hope this helps,
    George

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

Sidebar

Related Questions

I'm new in android, here i'm using Gallery to show images in my application,
I want to show nine images in a table , three images in each
I want to show my custom objects (images, formulas) in UITableView row name. Is
i have 10 images and i want to show they with numbers(1,2,3,4,5...). I am
I want to show the image that mobile phone's camera its taking on a
I made a simple gallery, using this script to show the images: $rs =
Hi I want to show an image gallery on my site and then have
i want to show a gallery kind of thing with the help of a
I'm using fancybox to show some images in a gallery. I have a main
I want to show image in a crystal report. Scenario is something like this.

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.