Simple directory picker Activity
Add in your build.gradle
:
android {
...
defaultConfig {
...
vectorDrawables.useSupportLibrary = true
}
...
}
...
dependencies {
...
implementation 'com.android.support:appcompat-v7:26+'
implementation 'com.android.support:recyclerview-v7:26+'
compile 'com.android.support:support-vector-drawable:26+'
}
/res
directory contains all necessary resources. Colors optimized for default (dark) AppCompat
theme.
To start DirPicker
use:
public class MainActivity extends AppCompatActivity {
...
private static final int REQUEST_CHOOSE_DIR = 1;
...
void choosePath () {
Intent intent = new Intent(this, DirPickerActivity.class);
startActivityForResult(intent, REQUEST_CHOOSE_DIR);
}
...
}
To get choosed path use:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent i) {
if (requestCode == REQUEST_CHOOSE_DIR && resultCode == RESULT_OK) {
Uri data = i.getData();
if (data != null) {
String extPath = data.getPath();
}
}
}