One of the steps in building my app is to let the user select a folder in which some files are stored. How can i make this configurable, without hardcoding the directory. Is there any 3rd party library that i can use to do this ?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
@Vikram's link provides a dialog that you can use. You can then save the directory the user chose using Shared Preferences.
Here is a simple example on how to use Shared Preferences.
Another tutorial can be found here.
UPDATE: A switch suddenly turned on inside me to do something like this. Credits still go to schwiz in this answer for the base code used. :)
The code above acts like a mini file explorer that lists the files and folders of the Android File System. You use it like:
Answering your question: Add global key variables
initialize your SharedPreferences somewhere on onCreate before you use it:
and then you can add a positive button to the dialog
In your activity, instead of using the SDCard default directory you can
As Vikram pointed out. you also need to do this in your FileNameFilter so that the dialog will display directories ONLY.
Update: As noted in this SO answer, the parameters
dir
andfilename
does not refer to the same file. Thedir
parameter is the directory containing the file, whilefilename
is the filename of the file itself. To determine whether the filte itself is a directory, we need to create a new file from the parameters like so: