Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this tutorial we will discuss How File Chooser works in Android Studio . File Chooser allow users to select a file which is in phone memory.
Layout
In activity_main layout we take an ImageView and a textview. When we upload image then in textview we show file name and file path.
AndroidManifest
we need to provide permission for read external storage so we added permission.
MainActivity
In MainActivity we ask for permission and if there is already permission we can pick file. We are creeating new Intent ACTION_GET_CONTENT. we also added CATEGORY_OPENABLE for open category and then call startActivityForResult.
Here we will get data in onActivityResult function and here we check if request code is equals to MY_RESULT_CODE_FILECHOOSER then we will get file data. We can fetch data from FileUtils class.If we need file name and file path then we will call FileUtils function getFilleName and getPath().
FileUtils
We can get FileName and FilePath from this class.We are using IOUtils so we need to add dependency for this.
dependency for IOUtils
Please check attached image here we pick a file and you can see we are showing file name and file path in textview.
So Here we discussed How File Chooser works in Android Studio. Thanks for reading this blog and You can get other blogs from here
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.