Android Directory Picker Documentation

Integrating with an Android project in Eclipse

First, import the Directory Picker project into your workspace. Then, set up your app to reference the library as described in the Android documentation.

In the AndroidManifest.xml of your project, add an entry for the new Activity:
<activity android:name="net.bgreco.DirectoryPicker" />

Usage in an app

To launch a directory picker:

Intent intent = new Intent(this, DirectoryPicker.class);
// optionally set options here
startActivityForResult(intent, DirectoryPicker.PICK_DIRECTORY);

Then create or modify onActivityResult:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if(requestCode == DirectoryPicker.PICK_DIRECTORY && resultCode == RESULT_OK) {
		Bundle extras = data.getExtras();
		String path = (String) extras.get(DirectoryPicker.CHOSEN_DIRECTORY);
		// do stuff with path
	}
}

Setting options

After creating the Intent but before starting the activity, you can set the following options using intent.putExtra().

DirectoryPicker.START_DIR What directory to start the browser in. The user will be unable to navigate above this directory.
Type: String
Default: Environment.getExternalStorageDirectory() (Probably the SD card)
DirectoryPicker.ONLY_DIRS true to show only directories, false to show all files.
Type: boolean
Default: true
DirectoryPicker.SHOW_HIDDEN true to show hidden files, false to hide them.
Type: boolean
Default: false