Simple, Responsive & Easy To Use Library For Android
Warning: This library uses external legacy storage! android:requestLegacyExternalStorage="true". Please read more about it here: https://developer.android.com/training/data-storage/use-cases#opt-out-scoped-storage
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.BalioFVFX:Android-Simple-File-Explorer-Library:2.0.7'
}
Intent intent = new Intent(CONTEXT, SimpleFileExplorerActivity);
startActivityForResult(intent, REQUEST_CODE);
Intent intent = new Intent(CONTEXT, SimpleFileExplorerActivity);
intent.putExtra(SimpleFileExplorerActivity.ENABLE_DIRECTORY_SELECT_KEY, false);
startActivityForResult(intent, REQUEST_CODE);
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if(data != null){
String selectedAbsolutePath = data.getStringExtra(SimpleFileExplorerActivity.ON_ACTIVITY_RESULT_KEY);
Toast.makeText(CONTEXT, selectedAbsolutePath, Toast.LENGTH_SHORT).show();
}
}
Note: Always check if the data is null, otherwise exception may occur.
For example if the user doesn't select a directory / file and closes the file explorer data will be null.
SimpleFileResources.imageFileId = R.drawable.ic_my_custom_file;
SimpleFileResources.imageDirectoryId = R.drawable.ic_my_custom_directory;
SimpleFileResources.imageFileId = null;
SimpleFileResources.imageDirectoryId = null;