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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:08:24+00:00 2026-05-16T02:08:24+00:00

I am currently making an app which works with images. I need to implement

  • 0

I am currently making an app which works with images. I need to implement functionality where the user picks a file stored on the SD card. Once they pick the picture (using the Android gallery), the the file-location of the image will be sent to another Activity, where other work will be done upon it.

I have seen similar posts here on SO, but none to answer my question specifically. Basically this is the code I am doing when the user clicks the “Load a Picture” button:

// Create a new Intent to open the picture selector:
Intent loadPicture = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

// To start it, run the startActivityForResult() method:
startActivityForResult(loadPicture, SELECT_IMAGE);

From that code, I then have a onActivityResult() method to listen to the call-back:

// If the user tried to select an image:
if(requestCode == SELECT_IMAGE)
{
    // Check if the user actually selected an image:
    if(resultCode == Activity.RESULT_OK)
    {
        // This gets the URI of the image the user selected:
        Uri selectedImage = data.getData();

        // Create a new Intent to send to the next Activity:
        Intent i = new Intent(currentActivty.this, nextActivity.class);

        // ----------------- Problem Area -----------------
        // I would like to send the filename to the Intent object, and send it over.
        // However, the selectedImage.toString() method will return a
        // "content://" string instead of a file location.  How do I get a file
        // location from that URI object?
        i.putExtra("PICTURE_LOCATION", selectedImage.toString());

        // Start the activity outlined with the Intent above:
        startActivity(i);

As the code above states, the uri.toString() will return a content:// string instead of the file location of the selected picture. How do I obtain the file location?

Note: Another possible solution is to send over the content:// string and convert that into a Bitmap (which is what happens in the next Activity). However, I don’t know how to do that.

  • 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-16T02:08:24+00:00Added an answer on May 16, 2026 at 2:08 am

    I have found the answer to my own question. After doing some more searching, I finally stumbled upon a post here on SO which asks the same question here: android get real path by Uri.getPath().

    Unfortunately, the answer has a broken link. After some Google searching, I found the correct link to the site here: http://www.androidsnippets.org/snippets/130/ (I have verified that this code does indeed work.)

    However, I decided to take a different route. Since my next Activity is using an ImageView to display the picture, I am instead going to use the Uri content string for all methods that link to the next Activity.

    In the next Activity, I am using the ImageView.setImageUri() method.

    Here is the code I am doing in the next Activity to display the picture from the content:// string:

    // Get the content string from the previous Activity:
    picLocation = getIntent().getStringExtra("PICTURE_LOCATION");
    
    // Instantiate the ImageView object:
    ImageView imageViewer = (ImageView)findViewById(R.id.ImageViewer);
    
    // Convert the Uri string into a usable Uri:
    Uri temp = Uri.parse(picLocation);
    imageViewer.setImageURI(temp);
    

    I hope that this question and answer will be helpful to future Android developers.

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

Sidebar

Related Questions

No related questions found

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.