aFileChooser icon indicating copy to clipboard operation
aFileChooser copied to clipboard

Would be nice to be able to change dir into an external sd card.

Open dentex opened this issue 13 years ago • 3 comments

I tried the example code provided, prior to integrate aFileChooser in an app of mine I'm trying to develop. I haven't been able to change directory into my external sdcard (/storage/sdcard1 or /mnt/extSdCard), remaining into the internal one (/storage/sdcard0 or /mnt/sdcard). Other than this, It's a great opportunity to be able to use such a good coding example. Thanks.

dentex avatar Nov 30 '12 15:11 dentex

Yeah, right now it is just defaulting to Environment.getExternalStorageDirectory(). This could be configurable though, so I will expose the base directory as an option in the next release. Feel free to do so yourself, and submit a push request. :-)

I believe it should be an optional Bundle Extra, that FileChooserActivity can read in onCreate. It would be best to add a helper method to FileUtils. Something like:

public static Intent createGetContentIntent(String path) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("*/*"); 
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.putExtra(FileChooserActivity.PATH, path);
    return intent;
}

iPaulPro avatar Nov 30 '12 16:11 iPaulPro

Thanks for your suggestion. I'll see what I can do. Maybe I'll have to wait your next release, since, right now, I'm just a beginner, finding it's own way in Android programming.

dentex avatar Nov 30 '12 17:11 dentex

Hi, I beleive for external SD card support for a start it would be enough to change 47th line in FileChooserActivity:

from public static final String EXTERNAL_BASE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath(); to public static final String EXTERNAL_BASE_PATH = Environment.getExternalStorageDirectory().getParent();

Also, sometimes FileChooserActivity returns Uri and it is not very simple to get a File from returned Uri, so it would be great to use something like this:

public static String getRealPathFromURI(Context context, Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; CursorLoader loader = new CursorLoader(context, contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); }

This code will return real file path from Uri.

So, I will try to submit this changes after complete my project. Thank you for your aFileChooser.

litvinenkonikita avatar Apr 11 '13 10:04 litvinenkonikita