0

Note: all type of files

I used default Gallery Intent to show to storage but it shows the Goggle Drive Option along with local Storage I tried the following referals but nothing works for me.

Ref:

  1. How to let user select only local files using Intent in Android? 2 .https://stackoverflow.com/questions/27762377/android-why-intent-extra-local-only-shows-google-photos
  2. Is it possible to hide google drive while using Intent.ACTION_GET_CONTENT in android?

Used another library, to show the only local storage, it works fine but Requirement is, Need to show only local storage and its all file types along with file size which is not available in this library. Kindly suggest some other library like below with showing file size

Ref: https://github.com/codekidX/storage-chooser https://androidexample365.com/lets-user-choose-files-in-internal-or-external-storage-with-just-few-lines-of-code/

Vignesh S
  • 1
  • 3
  • `default Gallery Intent` ? Never heard of. What do you consider to be that? – blackapps Aug 05 '21 at 07:34
  • Intent intent = new Intent(); intent.setType("*/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.putExtra("android.content.extra.SHOW_ADVANCED", true); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intent, "Select File"), 10); I used above code as default Intent – Vignesh S Aug 05 '21 at 08:12

1 Answers1

0

Use the below code that will help you achieve the desired results:

        val selectedUri =
            Uri.parse(Environment.getExternalStorageDirectory().toString() + "/Pictures")
        val intent = Intent(Intent.ACTION_PICK)
        intent.data = selectedUri
        intent.type = "image/*"

        if (intent.resolveActivityInfo(context!!.packageManager, 0) != null) {
            startActivityForResult(
                intent,
                101
            )
        } else {
            // if you reach this place, it means there is no any file
            // explorer app installed on your device
        }
Hascher
  • 486
  • 1
  • 3
  • 12
  • Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory().toString()); Intent intent = new Intent(Intent.ACTION_PICK); intent.setData(selectedUri); intent.setType("*/*"); if (intent.resolveActivityInfo(mContext.getPackageManager(), 0) != null) { startActivityForResult(intent, 10); } else { } Make changes the code like above, If we mentioned either particular folder name or not, it return same result, Its Not showing the Storage things, Only Google Photo option is Visible – Vignesh S Aug 05 '21 at 09:09