public static boolean pickDirectory ( Activity activity , File startPath , int requestCode ) { PackageManager packageMgr = activity . getPackageManager ( ) ; for ( String [ ] intent : PICK_DIRECTORY_INTENTS ) { String intentAction = intent [ 0 ] ; String uriPrefix = intent [ 1 ] ; Intent startIntent = new Intent ( intentAction ) . putExtra ( "org.openintents.extra.TITLE" , activity . getString ( R . string . save_as ) ) . setData ( Uri . parse ( uriPrefix + startPath . getPath ( ) ) ) ; try { if ( startIntent . resolveActivity ( packageMgr ) != null ) { activity . startActivityForResult ( startIntent , requestCode ) ; return true ; } } catch ( ActivityNotFoundException e ) { showNoFilePickerError ( activity , e ) ; } } return false ; }
Tries to open a known file browsers to pick a directory .