Skip to content

Commit db644b8

Browse files
authored
Merge pull request #1 from kdpadhiyar/kdpadhiyar-patch-2
Method to find storage path of android devices for application storage
2 parents 6923bbb + f05d012 commit db644b8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,22 @@ static public void getSDCardApplicationDir(ReactApplicationContext ctx, Promise
297297
promise.reject("RNFetchBlob.getSDCardApplicationDir", "External storage not mounted");
298298
}
299299
}
300-
300+
// method for android
301+
public static String getSDCardApplicationDir(ReactApplicationContext ctx) {
302+
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
303+
try {
304+
final String path = ctx.getExternalFilesDir(null).getParentFile().getAbsolutePath();
305+
return path;
306+
} catch (Exception e) {
307+
e.printStackTrace();
308+
return "";
309+
}
310+
} else {
311+
Log.d("getSDCardApplicationDir","media is not mounted");
312+
return "";
313+
}
314+
}
315+
301316
/**
302317
* Static method that returns a temp file path
303318
* @param taskId An unique string for identify

0 commit comments

Comments
 (0)