Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Repository files navigation

FilePicker Library for Android

LicenseAPIjitPackMonthly DownloadsWeekly DownloadsAndroid Arsenal

A FilePicker library for Android for selecting multiple types of files and also to capture Images and Videos.

Sample Apk

Note

pic

Usage

Step 1: Add it in your root build.gradle at the end of repositories

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Step 2: Add the dependency

dependencies {
...
implementation 'com.github.jaiselrahman:FilePicker:1.3.2'
}

Step 3: Start FilePickerActivity using startActivityForResult(...).

Intentintent = newIntent(this, FilePickerActivity.class);
startActivityForResult(intent, FILE_REQUEST_CODE);

Step 4: Receive results in onActivityResult(...).

caseFILE_REQUEST_CODE:
ArrayList<MediaFile> files = data.getParcelableArrayListExtra(FilePickerActivity.MEDIA_FILES);
//Do something with filesbreak;

Configuration

The FilePickerActivity can be configured by using Configurations.Builder methods

Example

intent.putExtra(FilePickerActivity.CONFIGS, newConfigurations.Builder()
.setCheckPermission(true)
.setShowImages(true)
.enableImageCapture(true)
.setMaxSelection(10)
.setSkipZeroSizeFiles(true)
.build());

Builder Methods

MethodsDefault valueUses
setShowImages(boolean)trueWhether to load Images files
setShowVideos(boolean)trueWhether to load Videos files
setShowAudios(boolean)falseWhether to load Audio files
setShowFiles(boolean)falseWhether to load Files for given suffixes
enableImageCapture(boolean)falseEnables camera for capturing of images
enableVideoCapture(boolean)falseEnables camera for capturing of videos
setCheckPermission(boolean)falseWhether to request permissions on runtime for API >= 23 if not granted
setSuffixes(String...)"txt", "pdf", "html", "rtf", "csv", "xml",
"zip", "tar", "gz", "rar", "7z","torrent",
"doc", "docx", "odt", "ott",
"ppt", "pptx", "pps",
"xls", "xlsx", "ods", "ots"
Suffixes for file to be loaded, overrides default value
setMaxSelection(int)-1Maximum no of items to be selected, -1 for no limits
setSingleChoiceMode(boolean)falseCan select only one file, overrides setMaxSelection(int)
use setSelectedMediaFile(MediaFile) to set default selection
setSelectedMediaFile(MediaFile)nullDefault file selection in singleChoiceMode
setSelectedMediaFiles(ArrayList<MediaFile>)nullDefault files to be marked as selected
setSingleClickSelection(boolean)trueStart selection mode on single click else on long click
setSkipZeroSizeFiles(boolean)trueWhether to load zero byte sized files
setLandscapeSpanCount(int)5Grid items in landscape mode
setPortraitSpanCount(int)3Grid items in portrait mode
setImageSize(int)Screen width/portraitSpanCountSize of height, width of image to be loaded in Px
setRootPath(String)External storageSet custom directory path to load files from
setIgnorePaths(String... ignorePaths)nullRegex patterns of paths to ignore
setIgnoreNoMedia(boolean)trueWhether to ignore .nomedia file
setIgnoreHiddenFile(boolean)trueWhether to ignore hidden file

MediaFile methods

MethodDescription
long getId()Id of the file in MediaStore database
String getName()Name of file without suffix
String getPath()Absolute path of the file
long getSize()Size of the file
long getDate()Date when file is added to MediaStore database
String getMimeType()Mime type of the file
int getMediaType()One of TYPE_FILE, TYPE_IMAGE, TYPE_AUDIO, TYPE_VIDEO
long getDuration()Duration of Audio, Video files in ms, else 0
Uri getThumbnail()Album Art of Audio files
long getHeight()Height of Image, Video files in Px for API>=16, else 0
long getWidth()Width of Image, Video files in Px for API>=16, else 0
String getBucketId()Id of Parent Directory in MediaStore database
String getBucketName()Name of Parent Directory

Contributions

Feel free to contribute to this project. Before creating issues or pull request please take a look at following templates.

Credits

License

Copyright (c) 2018, Jaisel Rahman
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Releases

Sponsor this project

Packages

Used by

Contributors

Languages