类 FileDialog
- java.lang.Object
-
- com.github.donmor.filedialog.lib.FileDialog
-
public abstract class FileDialog extends java.lang.ObjectThe class FileDialog provides a set of methods to open dialogs for file-operating. It contains a set of static methods opening AlertDialogs to choose files or a directory, and a callback providing a java.io.File array contains files or directory chosen for further usages. Make sure that WRITE_EXTERNAL_STORAGE permission of the app have been set to GRANTED if API level is higher than 22, and "android.defaultConfig.vectorDrawables.useSupportLibrary = true" should be added into build.gradle of the app if API level is lower than 21.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interfaceFileDialog.OnFileTouchedListenerThe call back that will be run when the dialog is closed.
-
字段概要
字段 修饰符和类型 字段 说明 static FileDialogFilterALLThis FileDialogFilter accepts all kinds of files.static java.lang.StringMIME_ALLThe constant MIME_ALL(*/*).
-
构造器概要
构造器 构造器 说明 FileDialog()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidfileDialog(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, int mode, int filterIndex, FileDialogFilter[] filters, boolean showHidden, boolean ignoreReadOnly, FileDialog.OnFileTouchedListener listener)Open a dialog to select folder or files.static voidfileDialog(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, int mode, int filterIndex, java.lang.String[] mimes, int det, boolean showHidden, boolean ignoreReadOnly, FileDialog.OnFileTouchedListener listener)Open a dialog to select folder or files.static voidfileOpen(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.static voidfileOpen(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.static voidfileOpen(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.static voidfileOpen(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.static voidfileOpenMultiple(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.static voidfileOpenMultiple(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.static voidfileOpenMultiple(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.static voidfileOpenMultiple(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.static voidfileSave(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.lang.String filename, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSave(android.content.Context parent, java.lang.String filename, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.static voidfileSelectDirectory(android.content.Context parent, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.static voidfileSelectDirectory(android.content.Context parent, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.static voidfileSelectDirectory(android.content.Context parent, java.io.File startDirectory, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.static voidfileSelectDirectory(android.content.Context parent, java.io.File startDirectory, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.static java.io.File[]getStorage(android.content.Context context, boolean ignoreReadOnly)Return an array contains file paths of all storage devices mounted.
-
-
-
字段详细资料
-
MIME_ALL
public static final java.lang.String MIME_ALL
The constant MIME_ALL(*/*).- 另请参阅:
- 常量字段值
-
ALL
public static final FileDialogFilter ALL
This FileDialogFilter accepts all kinds of files.
-
-
方法详细资料
-
fileOpen
public static void fileOpen(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileOpenMultiple
public static void fileOpenMultiple(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileSelectDirectory
public static void fileSelectDirectory(android.content.Context parent, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.- 参数:
parent- The parent Context.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.lang.String filename, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.filename- The default filename.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileOpen
public static void fileOpen(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileOpenMultiple
public static void fileOpenMultiple(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSelectDirectory
public static void fileSelectDirectory(android.content.Context parent, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.- 参数:
parent- The parent Context.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.lang.String filename, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.filename- The default filename.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileOpen
public static void fileOpen(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileOpenMultiple
public static void fileOpenMultiple(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileSelectDirectory
public static void fileSelectDirectory(android.content.Context parent, java.io.File startDirectory, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, FileDialogFilter[] filters, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filename- The default filename.filters- This parameter provides a set of filters.listener- The call back that will be run when the dialog is closed.
-
fileOpen
public static void fileOpen(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a single file to be opened.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileOpenMultiple
public static void fileOpenMultiple(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select multiple files to be opened.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSelectDirectory
public static void fileSelectDirectory(android.content.Context parent, java.io.File startDirectory, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a directory.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.io.File startDirectory, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileSave
public static void fileSave(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, FileDialogFilter[] filters, boolean showHidden, FileDialog.OnFileTouchedListener listener)Open a dialog to select a file path to be saved.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. if invalid, the dialog will start with the default SD card directory.filename- The default filename.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.listener- The call back that will be run when the dialog is closed.
-
fileDialog
public static void fileDialog(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, int mode, int filterIndex, FileDialogFilter[] filters, boolean showHidden, boolean ignoreReadOnly, FileDialog.OnFileTouchedListener listener)Open a dialog to select folder or files. All parameters are required using this method.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. If invalid, the dialog will start with the default SD card directory.filename- The default filename for fileSave mode. It will be ignored in other modes.mode- This parameter decides the type of the dialog. 0 for fileOpen, 1 for fileOpenMultiple, 2 for fileSelectDirectory, and 3 for fileSave.filterIndex- This parameter provides the default position of filter spinner. Usually its value is 0, and it will be reset if an invalid value was passed.filters- This parameter provides a set of filters.showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.ignoreReadOnly- This parameter decides whether read-only status of a device will be ignored, for example, most of systems prevents third part apps from writing to external SD cards.listener- The call back that will be run when the dialog is closed.
-
fileDialog
public static void fileDialog(android.content.Context parent, java.io.File startDirectory, java.lang.String filename, int mode, int filterIndex, java.lang.String[] mimes, int det, boolean showHidden, boolean ignoreReadOnly, FileDialog.OnFileTouchedListener listener)Open a dialog to select folder or files. All parameters are required using this method.- 参数:
parent- The parent Context.startDirectory- The directory the dialog will start with. If invalid, the dialog will start with the default SD card directory.filename- The default filename for fileSave mode. It will be ignored in other modes.mode- This parameter decides the type of the dialog. 0 for fileOpen, 1 for fileOpenMultiple, 2 for fileSelectDirectory, and 3 for fileSave.filterIndex- This parameter provides the default position of filter spinner. Usually its value is 0, and it will be reset if an invalid value was passed.mimes- The MIME types strings. Each String should be formatted like "type/subtype". Use "*/*" for all types. The string array will be firstly trimmed, if one of the strings matches none of common MIME types, it will be ignored, and "*/*" will be used if no valid string passed in.det- The detail level of mime-type filter. 0 for original MIME types strings, 1 for all of the extensions matches the MIME types, and 2 for both(not recommend because the filter spinner could be too long).showHidden- This parameter decides whether hidden(starts with '.') files could be shown or be created.ignoreReadOnly- This parameter decides whether read-only status of a device will be ignored, for example, most of systems prevents third part apps from writing to external SD cards.listener- The call back that will be run when the dialog is closed.
-
getStorage
public static java.io.File[] getStorage(android.content.Context context, boolean ignoreReadOnly)Return an array contains file paths of all storage devices mounted.- 参数:
context- The parent Context.ignoreReadOnly- This parameter decides whether read-only status of a device will be ignored, for example, most of systems prevents third part apps from writing to external SD cards.- 返回:
- the file [ ]
-
-