Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"));


            }
       });
like image 334
user3269466 Avatar asked Feb 04 '14 05:02

user3269466


2 Answers

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

like image 166
Ayaz Alifov Avatar answered Oct 21 '22 20:10

Ayaz Alifov


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"));


            }
       });
like image 27
rajshree Avatar answered Oct 21 '22 22:10

rajshree