Trying Open A Specific Folder In Android Using Intent
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); conf
Solution 1:
It works:
UriselectedUri= Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/");
Intentintent=newIntent(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
Solution 2:
try to replace your code with this line
btn.setOnClickListener(newView.OnClickListener()
{
@OverridepublicvoidonClick(View v)
{
Intentintent=newIntent(Intent.ACTION_GET_CONTENT);
Uriuri= Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/myFolder/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
}
});
Solution 3:
I found a solution in this GitHub repo
The code :
If you want open & browse file:FileBrowser.class
Intent intent = newIntent(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 = newIntent(activity, FileChooser::class.java)
intent.putExtra(Constants.INITIAL_DIRECTORY, File(storageDirPath).absolutePath)
startActivityForResult(intent, CODE_INTENT )
Solution 4:
Pick root:
IntentselectFile=newIntent();
selectFile.setAction("com.sec.android.app.myfiles.PICK_DATA_MULTIPLE");
selectFile.putExtra("CONTENT_TYPE", "*/*");
selectFile.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(selectFile);
Post a Comment for "Trying Open A Specific Folder In Android Using Intent"