Last Updated: September 09, 2019
·
4.093K
· alberovalley

Start android image picker for local files only

When we start the android image picker, unless we specify otherwise, it will display images both local and remote. If we intend to work only with local images, this is the way to go

// this starts the image picker
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); // this is the flag that does the trick
startActivityForResult(photoPickerIntent, SELECT_PHOTO);  


// this goes in onActivityResult(int requestCode, int resultCode, Intent data)
case SELECT_PHOTO:
    if(resultCode == Activity.RESULT_OK){
        Uri imageUri = data.getData();
        // do stuff with the imageUri
    }

1 Response
Add your response

Too bad it's only available from the level 11:
http://developer.android.com/reference/android/content/Intent.html#EXTRA_LOCAL_ONLY

Good tips, though!

over 1 year ago ·