Trying open a specific folder in android using intent [duplicate]
Asked Answered
P

4

20

I am trying to open a specific folder in android ?Is it possible to open a specific folder ???? this is the code i m using

    config=(Button)findViewById(R.id.btn_cf);

      config.setOnClickListener(new View.OnClickListener() 
      {         
            @Override
            public void onClick(View v)
            { 

            Intent intent = new Intent("Intent.ACTION_GET_CONTENT"); 
             Uri uri = Uri.parse("mnt/sdcard/myfiles/allfiles/download"); 
            intent.setDataAndType(uri, "*/*"); 
            startActivity(Intent.createChooser(intent, "download"));


            }
       });
Peltry answered 4/2, 2014 at 5:4 Comment(1)
have you tried this link #17166472Rey
N
5

It works:

Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
startActivity(intent); 

Have a nice codding :)

EDIT: If the current solution doesn't help you, then these file/directory choosers libraries can be helpful: https://android-arsenal.com/tag/35

Neron answered 30/10, 2014 at 11:35 Comment(4)
Error: No Activity found to handle PATH, Type="resource/folder"Methaemoglobin
Alauddin Ansari, maybe because you don't have any file manager app installed on your device. Please, check it.Neron
I've "Root Explorer" installed on my device. Also there is default file manager. But still getting error.Methaemoglobin
this code is only work if you have ES file explorer. need to change the setDataTypeOrran
D
1

try to replace your code with this line

  btn.setOnClickListener(new View.OnClickListener() 
      {         
            @Override
            public void onClick(View v)
            { 

                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
                    + "/myFolder/");
                intent.setDataAndType(uri, "text/csv");
                startActivity(Intent.createChooser(intent, "Open folder"));


            }
       });
Den answered 4/2, 2014 at 5:12 Comment(4)
i did the same bt it says u login in drop box app and the sign upPeltry
i just want to open a specific folder on my sd cardPeltry
ya i am looking fotr your answerDen
#5114908 this linkDen
H
0

I found a solution in this GitHub repo

The code :

If you want open & browse file: FileBrowser.class

        Intent intent = new Intent(activity, FileBrowser::class.java)
        intent.putExtra(Constants.INITIAL_DIRECTORY, File(storageDirPath).absolutePath)
        intent.putExtra(Constants.ALLOWED_FILE_EXTENSIONS,"*")

        startActivityForResult(intent, CODE_INTENT )

If you want to get user chosen file's URI: FileChooser.class

        Intent intent = new Intent(activity, FileChooser::class.java)
        intent.putExtra(Constants.INITIAL_DIRECTORY, File(storageDirPath).absolutePath)
        startActivityForResult(intent, CODE_INTENT )
Hallock answered 19/4, 2018 at 8:21 Comment(0)
C
-1

Pick root:

Intent selectFile = new Intent(); 
                             selectFile.setAction("com.sec.android.app.myfiles.PICK_DATA_MULTIPLE");    
            selectFile.putExtra("CONTENT_TYPE", "*/*");
            selectFile.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(selectFile);
Condemn answered 4/4, 2014 at 10:14 Comment(1)
I want to set URI For this can you please help me ?Nerissa

© 2022 - 2024 — McMap. All rights reserved.