diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-04-18 19:36:25 -0700 |
---|---|---|
committer | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-04-18 19:36:25 -0700 |
commit | e56c963435040fff497d92798ebbf2b16d63403f (patch) | |
tree | 63cfcfb12fa30f72eea675d7bbe9ae61a25104b2 /README.md | |
download | OhMySAF-e56c963435040fff497d92798ebbf2b16d63403f.tar OhMySAF-e56c963435040fff497d92798ebbf2b16d63403f.tar.gz OhMySAF-e56c963435040fff497d92798ebbf2b16d63403f.tar.bz2 OhMySAF-e56c963435040fff497d92798ebbf2b16d63403f.zip |
First Commit
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..f918f2a --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# Oh My SAF + +Android [SAF](https://developer.android.com/guide/topics/providers/document-provider) helper. + +# Implement + +1. Add [maven.yuuta.moe](https://maven.yuuta.moe) repo to your module + +2. Add dependency: + +```grooxy +implementation 'moe.yuuta.ohmysaf:ohmysaf:<the latest version>' +``` + +# Main Features + +* Faster migrate - If you have an old project which uses `java.io.File` a lot and you would like to migrate to SAF, OMG. By using OhMySAF, you can just continue using `File` with a little hack. + +# Faster Migrate + +Imagine that you have an old project and its file operation codes look like: + +```java +File theFxxkFile = new File("xxx/xxx"); +if (theFxxkFile.isFile()) { + theFxxkFile.delete(); + theFxxkFile.mkdir(); // In fact, SAF does not support that. +} +``` + +If you want to switch to SAF, the normal code will look like: + +```java +// Assume that you've got the URI +DocumentFile theFxxkFile = DocumentFile.fromTreeUri(context, uri); +if (theFxxkFile.isFile()) { + theFxxkFile.delete(); + // ..... +} +``` + +One day you discovered `OhMySAF`, your problem is solved: + +```java +// Assume that you've got the URI + +// Magic +File theFxxkFile = OhMySAF.ohMyTree(context, uri); + +// Just KEEP these old codes! +if (theFxxkFile.isFile()) { + theFxxkFile.delete(); + theFxxkFile.mkdir(); // In fact, SAF does not support that. +} +``` + +# Licenses + +Apache 2.0
\ No newline at end of file |