Open folder in Android/Xamarin.Android programatically
I want to open folder programatically. I used the below code but no luck
Intent intent = new Intent(Intent.ActionView);
var uri=Uri.Parse("/storage/emulated/0/myFolder");
intent.SetDataAndType(uri, "*/*");
intent.SetFlags(ActivityFlags.NewTask);
// activity.StartActivity(Intent.CreateChooser(intent, "choose folder"));
activity.StartActivity(intent);
It shows various apps like Phone, Messaging, ES File Explorer, contacts etc. I want to open the default file explorer to open that folder.
android xamarin.android
add a comment |
I want to open folder programatically. I used the below code but no luck
Intent intent = new Intent(Intent.ActionView);
var uri=Uri.Parse("/storage/emulated/0/myFolder");
intent.SetDataAndType(uri, "*/*");
intent.SetFlags(ActivityFlags.NewTask);
// activity.StartActivity(Intent.CreateChooser(intent, "choose folder"));
activity.StartActivity(intent);
It shows various apps like Phone, Messaging, ES File Explorer, contacts etc. I want to open the default file explorer to open that folder.
android xamarin.android
add a comment |
I want to open folder programatically. I used the below code but no luck
Intent intent = new Intent(Intent.ActionView);
var uri=Uri.Parse("/storage/emulated/0/myFolder");
intent.SetDataAndType(uri, "*/*");
intent.SetFlags(ActivityFlags.NewTask);
// activity.StartActivity(Intent.CreateChooser(intent, "choose folder"));
activity.StartActivity(intent);
It shows various apps like Phone, Messaging, ES File Explorer, contacts etc. I want to open the default file explorer to open that folder.
android xamarin.android
I want to open folder programatically. I used the below code but no luck
Intent intent = new Intent(Intent.ActionView);
var uri=Uri.Parse("/storage/emulated/0/myFolder");
intent.SetDataAndType(uri, "*/*");
intent.SetFlags(ActivityFlags.NewTask);
// activity.StartActivity(Intent.CreateChooser(intent, "choose folder"));
activity.StartActivity(intent);
It shows various apps like Phone, Messaging, ES File Explorer, contacts etc. I want to open the default file explorer to open that folder.
android xamarin.android
android xamarin.android
asked 2 days ago
Amit
7110
7110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Hi @Amit if want to open the default file explorer, you can do that in Native Android:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");//set type , here is setted to every type.
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent,1);
Other types :
intent.setType("image/*"); //set type be image
intent.setType("audio/*"); //set type be audio
intent.setType("video/*"); //set type be video (mp4 3gp be suported in android)
intent.setType("video/*;image/*");//set type be all video and image
And when back to app ,can deal with file in here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//no choose no continue to here
Uri uri = data.getData();
//get file's url , so last can get file
String proj = {MediaStore.Images.Media.DATA};
Cursor actualimagecursor = managedQuery(uri, proj, null, null, null);
int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
String img_path = actualimagecursor.getString(actual_image_column_index);
File file = new File(img_path);
Toast.makeText(MainActivity.this, file.toString(), Toast.LENGTH_SHORT).show();
}
}
Also in this way can open the specified file, need to use method setDataAndType
like follow:
intent.setDataAndType(Uri.fromFile(dir.getParentFile()), "file/*.txt");
the dir
is the File
folder where file in this,like follow:
String compName = AppString.getCompanyName();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + compName + "/OSC_DATA/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
The main problem ofIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.
– Amit
yesterday
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945333%2fopen-folder-in-android-xamarin-android-programatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hi @Amit if want to open the default file explorer, you can do that in Native Android:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");//set type , here is setted to every type.
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent,1);
Other types :
intent.setType("image/*"); //set type be image
intent.setType("audio/*"); //set type be audio
intent.setType("video/*"); //set type be video (mp4 3gp be suported in android)
intent.setType("video/*;image/*");//set type be all video and image
And when back to app ,can deal with file in here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//no choose no continue to here
Uri uri = data.getData();
//get file's url , so last can get file
String proj = {MediaStore.Images.Media.DATA};
Cursor actualimagecursor = managedQuery(uri, proj, null, null, null);
int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
String img_path = actualimagecursor.getString(actual_image_column_index);
File file = new File(img_path);
Toast.makeText(MainActivity.this, file.toString(), Toast.LENGTH_SHORT).show();
}
}
Also in this way can open the specified file, need to use method setDataAndType
like follow:
intent.setDataAndType(Uri.fromFile(dir.getParentFile()), "file/*.txt");
the dir
is the File
folder where file in this,like follow:
String compName = AppString.getCompanyName();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + compName + "/OSC_DATA/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
The main problem ofIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.
– Amit
yesterday
add a comment |
Hi @Amit if want to open the default file explorer, you can do that in Native Android:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");//set type , here is setted to every type.
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent,1);
Other types :
intent.setType("image/*"); //set type be image
intent.setType("audio/*"); //set type be audio
intent.setType("video/*"); //set type be video (mp4 3gp be suported in android)
intent.setType("video/*;image/*");//set type be all video and image
And when back to app ,can deal with file in here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//no choose no continue to here
Uri uri = data.getData();
//get file's url , so last can get file
String proj = {MediaStore.Images.Media.DATA};
Cursor actualimagecursor = managedQuery(uri, proj, null, null, null);
int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
String img_path = actualimagecursor.getString(actual_image_column_index);
File file = new File(img_path);
Toast.makeText(MainActivity.this, file.toString(), Toast.LENGTH_SHORT).show();
}
}
Also in this way can open the specified file, need to use method setDataAndType
like follow:
intent.setDataAndType(Uri.fromFile(dir.getParentFile()), "file/*.txt");
the dir
is the File
folder where file in this,like follow:
String compName = AppString.getCompanyName();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + compName + "/OSC_DATA/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
The main problem ofIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.
– Amit
yesterday
add a comment |
Hi @Amit if want to open the default file explorer, you can do that in Native Android:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");//set type , here is setted to every type.
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent,1);
Other types :
intent.setType("image/*"); //set type be image
intent.setType("audio/*"); //set type be audio
intent.setType("video/*"); //set type be video (mp4 3gp be suported in android)
intent.setType("video/*;image/*");//set type be all video and image
And when back to app ,can deal with file in here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//no choose no continue to here
Uri uri = data.getData();
//get file's url , so last can get file
String proj = {MediaStore.Images.Media.DATA};
Cursor actualimagecursor = managedQuery(uri, proj, null, null, null);
int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
String img_path = actualimagecursor.getString(actual_image_column_index);
File file = new File(img_path);
Toast.makeText(MainActivity.this, file.toString(), Toast.LENGTH_SHORT).show();
}
}
Also in this way can open the specified file, need to use method setDataAndType
like follow:
intent.setDataAndType(Uri.fromFile(dir.getParentFile()), "file/*.txt");
the dir
is the File
folder where file in this,like follow:
String compName = AppString.getCompanyName();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + compName + "/OSC_DATA/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
Hi @Amit if want to open the default file explorer, you can do that in Native Android:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");//set type , here is setted to every type.
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent,1);
Other types :
intent.setType("image/*"); //set type be image
intent.setType("audio/*"); //set type be audio
intent.setType("video/*"); //set type be video (mp4 3gp be suported in android)
intent.setType("video/*;image/*");//set type be all video and image
And when back to app ,can deal with file in here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//no choose no continue to here
Uri uri = data.getData();
//get file's url , so last can get file
String proj = {MediaStore.Images.Media.DATA};
Cursor actualimagecursor = managedQuery(uri, proj, null, null, null);
int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToFirst();
String img_path = actualimagecursor.getString(actual_image_column_index);
File file = new File(img_path);
Toast.makeText(MainActivity.this, file.toString(), Toast.LENGTH_SHORT).show();
}
}
Also in this way can open the specified file, need to use method setDataAndType
like follow:
intent.setDataAndType(Uri.fromFile(dir.getParentFile()), "file/*.txt");
the dir
is the File
folder where file in this,like follow:
String compName = AppString.getCompanyName();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + compName + "/OSC_DATA/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
answered yesterday
Junior Jiang - MSFT
32216
32216
The main problem ofIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.
– Amit
yesterday
add a comment |
The main problem ofIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.
– Amit
yesterday
The main problem of
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.– Amit
yesterday
The main problem of
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
is: It opens the file browser window and when user click on any items, its closes and returns to the main activity of the app. I don't want user to pick the content (as Get_Content do). I just want to open the folder just like we open the link in the browser and user is free to do with that.– Amit
yesterday
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945333%2fopen-folder-in-android-xamarin-android-programatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown