{"id":13644742,"url":"https://github.com/adityak368/Android-FileBrowser-FilePicker","last_synced_at":"2025-04-21T10:34:17.360Z","repository":{"id":144357340,"uuid":"88528851","full_name":"adityak368/Android-FileBrowser-FilePicker","owner":"adityak368","description":"A FileBrowser / FileChooser / FolderChooser for Android that you can integrate to your app to browse/select files from internal/external storage ","archived":false,"fork":false,"pushed_at":"2020-06-08T21:29:10.000Z","size":623,"stargazers_count":169,"open_issues_count":8,"forks_count":45,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-09T17:42:18.674Z","etag":null,"topics":["android","androidfilepicker","browser","filebrowser","filechooser","filesearch","fileselector","filesystem","folderchooser"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adityak368.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-17T16:46:18.000Z","updated_at":"2024-11-07T11:10:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"19cd3275-ff85-47d7-91fe-db46f677b414","html_url":"https://github.com/adityak368/Android-FileBrowser-FilePicker","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityak368%2FAndroid-FileBrowser-FilePicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityak368%2FAndroid-FileBrowser-FilePicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityak368%2FAndroid-FileBrowser-FilePicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityak368%2FAndroid-FileBrowser-FilePicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adityak368","download_url":"https://codeload.github.com/adityak368/Android-FileBrowser-FilePicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250040739,"owners_count":21365154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","androidfilepicker","browser","filebrowser","filechooser","filesearch","fileselector","filesystem","folderchooser"],"created_at":"2024-08-02T01:02:12.013Z","updated_at":"2025-04-21T10:34:12.340Z","avatar_url":"https://github.com/adityak368.png","language":"Java","readme":"# FileBrowser\n\nA FileBrowser / FileChooser for Android that you can integrate to your app to browse/select files from internal/external storage.\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--FileBrowser--FilePicker-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5636)\n\n# Using Maven\n``` xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.adityak\u003c/groupId\u003e\n  \u003cartifactId\u003ebrowsemyfiles\u003c/artifactId\u003e\n  \u003cversion\u003e1.9\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n# Or Using Gradle\n```\ncompile 'com.adityak:browsemyfiles:1.9'\n```\n\n\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305189/670232ec-2794-11e7-819f-b92f487b3075.png\" width=\"300\"\u003e   \u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305190/670328a0-2794-11e7-86ac-62b69af7b577.png\" width=\"300\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305188/6701de1e-2794-11e7-981f-7d6d0124b2b2.png\" width=\"300\"\u003e   \u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305187/6701b74a-2794-11e7-8057-c5677db858b0.png\" width=\"300\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305186/6701b33a-2794-11e7-8c58-d5da64e40768.png\" width=\"300\"\u003e   \u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305191/67038f8e-2794-11e7-8777-4bb0db870c31.png\" width=\"300\"\u003e\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25305192/6730cec2-2794-11e7-8ab0-9b696822520f.png\" width=\"300\"\u003e   \u003cimg src=\"https://cloud.githubusercontent.com/assets/19688735/25563142/0f8568ca-2db3-11e7-8782-f22bcce53fd1.png\" width=\"300\"\u003e\n\nIt easily integrates with your app's color scheme. You can change the color scheme using the following in your styles.xml\n\n``` xml\n\u003citem name=\"colorPrimary\"\u003e@color/colorPrimary\u003c/item\u003e\n\u003citem name=\"colorPrimaryDark\"\u003e@color/colorPrimaryDark\u003c/item\u003e\n\u003citem name=\"colorAccent\"\u003e@color/colorAccent\u003c/item\u003e\n\u003citem name=\"android:actionModeBackground\"\u003e@color/actionModeToolbar\u003c/item\u003e\n```\n\nThere are 3 main classes to use the library.\n\n1. FileBrowser - Used to just Browse files in storage (has all file IO features)\n2. FileChooser - Used to select single/multiple files in storage (has some IO features)\n3. FolderChooser - Used to select single/multiple folders in storage (has some IO features)\n4. FileBrowserWithCustomHandler - Used to run custom code when files are selected (has all IO features)\n\n# 1. FileBrowser\nUse following Intent to start the FileBrowser\n\n``` java\nIntent i4 = new Intent(getApplicationContext(), FileBrowser.class);\nstartActivity(i4);\n```\n\n# 2. FileChooser\n\nUse following Intent to start the FileChooser\n  - For Single Selection\n\n``` java\nIntent i2 = new Intent(getApplicationContext(), FileChooser.class);\ni2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());\nstartActivityForResult(i2, PICK_FILE_REQUEST);\n```\n\n\nTo get the selected file, In your calling activity's onActivityResult method, use the following\n\n```java\n\nif (requestCode == PICK_FILE_REQUEST \u0026\u0026 data!=null) {\n      if (resultCode == RESULT_OK) {\n          Uri file = data.getData();\n      }\n}\n        \n```\n\n\n  - For Multiple Selection\n``` java\nIntent i2 = new Intent(getApplicationContext(), FileChooser.class);\ni2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.MULTIPLE_SELECTION.ordinal());\nstartActivityForResult(i2, PICK_FILE_REQUEST);\n```\n\nTo get the selected file, In your calling activity's onActivityResult method, use the following\n\n```java\n\nif (requestCode == PICK_FILE_REQUEST \u0026\u0026 data!=null) {\n      if (resultCode == RESULT_OK) {\n          ArrayList\u003cUri\u003e selectedFiles  = data.getParcelableArrayListExtra(Constants.SELECTED_ITEMS);\n      }\n}\n        \n```\n\n# 3. FolderChooser\n\nUse following Intent to start the FolderChooser\n  - For Single Selection\n\n``` java\nIntent i2 = new Intent(getApplicationContext(), FolderChooser.class);\ni2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());\nstartActivityForResult(i2, PICK_FOLDER_REQUEST);\n```\n\nTo get the selected folder, In your calling activity's onActivityResult method, use the following\n\n```java\n\nif (requestCode == PICK_FOLDER_REQUEST \u0026\u0026 data!=null) {\n      if (resultCode == RESULT_OK) {\n          Uri file = data.getData();\n      }\n}\n        \n```\n\n  - For Multiple Selection\n``` java\nIntent i2 = new Intent(getApplicationContext(), FolderChooser.class);\ni2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.MULTIPLE_SELECTION.ordinal());\nstartActivityForResult(i2, PICK_FOLDER_REQUEST);\n```\n\nTo get the selected file, In your calling activity's onActivityResult method, use the following\n\n```java\n\nif (requestCode == PICK_FOLDER_REQUEST \u0026\u0026 data!=null) {\n      if (resultCode == RESULT_OK) {\n          ArrayList\u003cUri\u003e selectedFiles  = data.getParcelableArrayListExtra(Constants.SELECTED_ITEMS);\n      }\n}\n        \n```\n\n# 4. FileBrowserWithCustomHandler\n\nRegister a Broadcast receiver and handle the onReceive method like below\n\n```java\n\npublic class FileSelectedBroadCastReceiver extends BroadcastReceiver {\n    @Override\n    public void onReceive(Context context, Intent intent) {\n         Uri filePath = intent.getParcelableExtra(com.aditya.filebrowser.Constants.BROADCAST_SELECTED_FILE);\n    }\n}\n\n```\n\nRegister the receiver like the following snippet \n\n``` xml\n\n        \u003creceiver android:name=\".FileSelectedBroadCastReceiver\"\n            android:exported=\"false\"\n            android:enabled=\"true\"\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"com.adityak.filebrowser.FILE_SELECTED_BROADCAST\" /\u003e\n            \u003c/intent-filter\u003e\n        \u003c/receiver\u003e\n        \n```\n\nIf you also need some other parameters to be sent with the broadcast use the following when creating the activity\n``` java\n\nIntent i = new Intent(mContext, FileBrowserWithCustomHandler.class);\nBundle ib = new Bundle();\n//add extras\ni.putExtras(ib);\nstartActivity(i);\n\n```\nand in the broadcast receiver use the following to get the extras\n\n``` java\nBundle b = intent.getExtras()\n```\n\n\n### To load a particular directory instead of the normal root directory\nAdd the following in the intent\n``` java\nIntent i = new Intent(this, FileBrowser.class); //works for all 3 main classes (i.e FileBrowser, FileChooser, FileBrowserWithCustomHandler)\ni.putExtra(Constants.INITIAL_DIRECTORY, new File(Environment.getExternalStorageDirectory().getAbsolutePath(),\"Movies\").getAbsolutePath());\n```\n\n\n### To list only the files with a particular extension\nAdd the following in the intent\n``` java\nIntent i = new Intent(this, FileBrowser.class); //works for all 3 main classes (i.e FileBrowser, FileChooser, FileBrowserWithCustomHandler)\ni.putExtra(Constants.ALLOWED_FILE_EXTENSIONS, \"mkv;mp4;avi\");\n```\n\nUse file extensions delimited by semicolon\n\n### Known Issues\nCurrently folder size is calculated using Java's Api getTotalSpace() which gives the size of the partition of the path which may not always give the desired result.\nTo get the exact size, properties can be used which gives the exact result. If Exact size is to be known, then UI would lag as it would take some time to calculate size - Fix for this is postponed\n\n\nIf you have any questions/queries/Bugs/Hugs please mail @\nadityak368@gmail.com\n","funding_links":[],"categories":["文件操作"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityak368%2FAndroid-FileBrowser-FilePicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityak368%2FAndroid-FileBrowser-FilePicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityak368%2FAndroid-FileBrowser-FilePicker/lists"}