From e884fc2abcdac8fa11c7ca3215468565d57c3ca2 Mon Sep 17 00:00:00 2001 From: Andrew Shini Date: Fri, 17 Jun 2016 11:48:16 +1000 Subject: [PATCH] Add ExternalStorageDirectoryPath --- FS.common.js | 1 + README.md | 3 ++- android/src/main/java/com/rnfs/RNFSManager.java | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/FS.common.js b/FS.common.js index 24264b6..837a194 100644 --- a/FS.common.js +++ b/FS.common.js @@ -250,6 +250,7 @@ var RNFS = { CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath, DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath, ExternalDirectoryPath: RNFSManager.NSExternalDirectoryPath, + ExternalStorageDirectoryPath: RNFSManager.NSExternalStorageDirectoryPath, TemporaryDirectoryPath: RNFSManager.NSTemporaryDirectoryPath, LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath, PicturesDirectoryPath: RNFSManager.NSPicturesDirectoryPath diff --git a/README.md b/README.md index b3fd835..23f5bff 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,8 @@ The following constants are available on the `RNFS` export: - `CachesDirectoryPath` (`String`) The absolute path to the caches directory - `DocumentDirectoryPath` (`String`) The absolute path to the document directory - `TemporaryDirectoryPath` (`String`) The absolute path to the temporary directory (iOS only) -- `ExternalDirectoryPath` (`String`) The absolute path to the external, shared directory (android only) +- `ExternalDirectoryPath` (`String`) The absolute path to the external files, shared directory (android only) +- `ExternalStorageDirectoryPath` (`String`) The absolute path to the external storage, shared directory (android only) ### `promise readDir(path)` diff --git a/android/src/main/java/com/rnfs/RNFSManager.java b/android/src/main/java/com/rnfs/RNFSManager.java index 7fe1b24..90db1fb 100644 --- a/android/src/main/java/com/rnfs/RNFSManager.java +++ b/android/src/main/java/com/rnfs/RNFSManager.java @@ -40,6 +40,7 @@ public class RNFSManager extends ReactContextBaseJavaModule { private static final String NSDocumentDirectoryPath = "NSDocumentDirectoryPath"; private static final String NSExternalDirectoryPath = "NSExternalDirectoryPath"; + private static final String NSExternalStorageDirectoryPath = "NSExternalStorageDirectoryPath"; private static final String NSPicturesDirectoryPath = "NSPicturesDirectoryPath"; private static final String NSTemporaryDirectoryPath = "NSTemporaryDirectoryPath"; private static final String NSCachesDirectoryPath = "NSCachesDirectoryPath"; @@ -345,6 +346,12 @@ public class RNFSManager extends ReactContextBaseJavaModule { } else { constants.put(NSExternalDirectoryPath, null); } + File externalStorageDirectory = this.getReactApplicationContext().getExternalStorageDirectory(null); + if (externalStorageDirectory != null) { + constants.put(NSExternalStorageDirectoryPath, externalStorageDirectory.getAbsolutePath()); + } else { + constants.put(NSExternalStorageDirectoryPath, null); + } constants.put(NSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()); constants.put(NSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); constants.put(NSFileTypeRegular, 0);