How to use intent for choosing file browser to select file
You can use something like this:
....
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, YOUR_RESULT_CODE);
....
But I really doubt that you can set a filter third-party file browsers.
Or you can try to use this file dialog: http://code.google.com/p/android-file-dialog/
How to Select File on android using Intent
the type of a file is .txt
Then use text/plain
as a MIME type. As Ian Lake noted in a comment, file/*
is not a valid MIME type.
Beyond that, delete getRealPathFromURI()
(which will not work). There is no path, beyond the Uri
itself. You can read in the contents identified by this Uri
by calling openInputStream()
on a ContentResolver
, and you can get a ContentResolver
by calling getContentResolver()
on your Activity
.
Select File from file manager via Intent
You can use this:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, REQUEST_CODE);
For samsung devices to open file manager use this:
Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
intent.putExtra("CONTENT_TYPE", "*/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
For more reference checkout http://developer.android.com/guide/topics/providers/document-provider.html
Pick any kind of file via an Intent in Android
Not for camera but for other files..
In my device I have ES File Explorer
installed and This simply thing works in my case..
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_REQUEST_CODE);
Android Select File Intent
My goal is to pic ANY file via the standard file manager of Android/Samsung.
Android does not have a "standard file manager".
If your minSdkVersion
is 19 or higher, you are welcome to use the Storage Access Framework (e.g., ACTION_OPEN_DOCUMENT
), which is the closest thing that Android now has to a "standard file manager".
Otherwise, you are limited to whatever ACTION_GET_CONTENT
-supporting apps that the user has installed, or creating your own file-selection UI, or using one of many existing libraries for selecting files.
android browse file intent with defined extension
I want file manager to show only txt files to user, so user couldn't choose file with wrong extension
That is not literally possible. You are welcome to use a MIME type of text/plain
instead of */*
, but:
- There is no guarantee that this will only return files with a
.txt
extension - There is no guarantee that there is any app on the device that can handle
ACTION_GET_CONTENT
of that MIME type - There is no guarantee that any "file manager" will honor your MIME type; they may elect to display all files anyway
Related Topics
Inserting Contacts in Android 2.2
Anr Keydispatchingtimedout Error
Receive Mms Messages in Android Kitkat
Broadcast Receiver to Detect Application Start
How to Implement Image Gallery in Gridview in Android
Trying to Uninstall_Shortcut But Shortcut Won't Go Away
Why Is Android Webview Refusing User Input
Is Google's Android Opengl Tutorial Teaching Incorrect Linear Algebra
Android Background Service Is Restarting When Application Is Killed
Custom Converter for Retrofit 2
Animation in Notification Bar Custom View
How to Disable All Views Inside the Layout
Android Wifi How to Detect When Specific Wifi Connection Is Available