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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:41:32+00:00 2026-06-01T06:41:32+00:00

I am new at this :) I am trying to load a picture from

  • 0

I am new at this 🙂
I am trying to load a picture from the sdcard into an ImageView in this way:

b_picture.setOnClickListener(new OnClickListener() {
    public void onClick(View v)  {
        Intent intent =  new Intent(Intent.ACTION_PICK,
                               MediaStore.Images.Media.INTERNAL_CONTENT_URI);
        startActivityForResult(intent, 0);
    }
});

Here I am trying to retrive the picture and change the ImageView:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);
     Bitmap bm = (Bitmap) data.getExtras().get("data");
     iv_picture.setImageBitmap(bm);     
}

And I get this from the logcat:

Failure delivering result ResultInfo {who=null, request=0, result=-1, 
            data=Intent { dat=content://media/external/images/media/2 

I can’t solve this problem. Can you help me? Thanks.

  • 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-01T06:41:34+00:00Added an answer on June 1, 2026 at 6:41 am

    The data associated with your returned Intent is not a bitmap. It’s a URI you can use to look up in the MediaStore ContentProvider to get back the image you want. 🙂

    You can find a mostly-working example over at this question.

    Edit: To expand:

    When you go off and query the MediaStore for an image, it isn’t returning you the actual image. It’s returning you a URI that you can use to look up the image. The way you translate that URI into an actual image is this:

    Your URI is content://media/external/images/media/2 as per the error message.

    So, we’ll basically create a query and run it on the MediaStore‘s ContentProvider, which is a database of images. Pass that URI into this function:

    public Bitmap loadFullImage( Context context, Uri photoUri  ) {
        Cursor photoCursor = null;
    
        try {
            // Attempt to fetch asset filename for image
    
            // DATA is the column name in the database for the filename of the image
            String[] projection = { MediaStore.Images.Media.DATA };
    
            // use the URI you were given in order to look up the right image,
            // and get a Cursor object that will iterate over the matching rows in the 
            // database.
            photoCursor = context.getContentResolver().query( photoUri, 
                                                    projection, null, null, null );
    
            // since we only care about one image...
            if ( photoCursor != null && photoCursor.getCount() == 1 ) {
    
                // go to the first row that was returned
                photoCursor.moveToFirst();
    
                // get the string in the DATA column at that row
                String photoFilePath = photoCursor.getString(
                    photoCursor.getColumnIndex(MediaStore.Images.Media.DATA) );
    
                // Load image from path
                return BitmapFactory.decodeFile( photoFilePath, null );
            }
        } finally {
    
            // close up the cursor
            if ( photoCursor != null ) {
                photoCursor.close();
            }
        }
    
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to php and I am getting this error trying to load
i am new kernel programming.i have been trying to load this driver program for
I am trying to have a picture to load onclick into an alert box
I am trying to display a jpg file from a server into an imageView.
Hey all. I'm really new at this obj-c/xcode stuff. I'm trying to load the
I'm trying to load all images from sdcard's phone on a GridView. I implemented
So I'm trying out this new TDD thing (about time haha). Anyways I have
I am all very new to this and am trying to use extended hex
I've been trying this: NSNumberFormatter *testNumber=[NSNumberFormatter new]; if (![testNumber numberFromString:someNSString]) I have been told
i am enthusiast and new in programming trying this simple c language code 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.