Update readme

This commit is contained in:
seven332 2016-11-28 01:38:31 +08:00
parent 96cb1ff0a1
commit 41daf0d0e5

View File

@ -2,23 +2,29 @@
UniFile 是基于 `android.support.v4.provider.DocumentFile`,而且更好用。
The UniFile is forked from `android.support.v4.provider.DocumentFile`, but more powerful.
区别有:
* 添加 listFiles(FilenameFilter)
* 添加 openOutputStream()openOutputStream(boolean)openInputStream()
* 添加 createRandomAccessFile(String)
* 添加 subFile(String)
* 添加其他文件 uri 支持
* 支持所有 ContentProvider 的 uri
* 支持 asset 文件的 uri`file:///android_asset/text/uccu.txt`
* 支持 resource 文件的 uri`android.resource://com.hippo.unifile.example/2130903040`
* 添加 getFilePath()
* 添加 listFiles(FilenameFilter)
* 添加 openOutputStream()openOutputStream(boolean append)openInputStream()
* 添加 createRandomAccessFile(String mode)
* 删除了 createFile 中 mimeType 参数
* 修改 createFilecreateDirectory 特性,避免出现文件名后添加 (1) 的现象
The UniFile is forked from `android.support.v4.provider.DocumentFile`, but more powerful.
The differences:
* Add listFiles(FilenameFilter)
* Add openOutputStream()openOutputStream(boolean)openInputStream()
* Add createRandomAccessFile(String)
* Add subFile(String)
* Add other file uri support
* Support all uri from ContentProvider
* Support all asset file uri, like `file:///android_asset/text/uccu.txt`
* Support all resource file uri, like `android.resource://com.hippo.unifile.example/2130903040`
* Add getFilePath()
* Add listFiles(FilenameFilter)
* Add openOutputStream()openOutputStream(boolean append)openInputStream()
* Add createRandomAccessFile(String mode)
* Remove mimeType in createFile function
* Avoid filename ending with (1) in createFilecreateDirectory
@ -42,9 +48,38 @@ Add UniFile as dependency in project `build.gradle`.
dependencies {
...
compile 'com.github.seven332:unifile:0.1.4'
compile 'com.github.seven332:unifile:1.0.0'
}
在代码中使用:
Use UniFile in your code:
```java
// 从 Uri 创建 UniFile
// Create UniFile from Uri
file = UniFile.fromUri(context, uri);
// 从 File 创建 UniFile
// Create UniFile from File
file = UniFile.fromFile(f);
// 从 asset path 创建 UniFile
// Create UniFile from asset path
file = UniFile.fromAsset(assetManager, path);
// 从 resource id 创建 UniFile
// Create UniFile from resource id
file = UniFile.fromResource(context, resId);
// 获取原始文件路径
// Get origin file path
path = file.getFilePath();
// 创建随机访问文件
// Create random access file
raf = file.createRandomAccessFile("rw");
```
# License