Selecting Images from gallery to app is a feature we generally see in messenger apps like whatsapp, facebook. and many more.. messaging apps  as the list is expanding day by day.

Also few apps where we need to upload our profile picture, apps like olx, quickr where we can sell goods online then we will be using this type of feature.

By using this feature we can get images from our gallery into image view from there we can upload the image or can do whatever we want it to be.

So now i think you have a basic information about what we are going to do here in this tutorial, i.e., android studio tutorial on selecting an image from gallery.

Creating activity_main.xml :

We need to place the selected image into imageview, add a imageview and also place a button for selecting a image.



now we have our layout file ready then we need to do necessary coding to select image


Creating MainActivity :


We need to use a intent for picking up a image url



now we got image url then we need to query image using cursor



now set the image to imageview  full coding





Permission : 

We need to add a permission by which we can access gallery on android device.






Output :


Show Buttons
Hide Buttons
Read previous post:
General Mistake in Simple Toast