Check Mobile App
Read now
Start a Project

How File Chooser works in Android Studio

Save

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.

filePicker

So Here we discussed  How File Chooser works in Android Studio. Thanks for reading this blog and You can get other blogs from here

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Osama
Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home