@@ -252,16 +252,16 @@ static Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
252252
253253 res .put ("DocumentDir" , ctx .getFilesDir ().getAbsolutePath ());
254254 res .put ("CacheDir" , ctx .getCacheDir ().getAbsolutePath ());
255- res .put ("DCIMDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_DCIM ).getAbsolutePath ());
256- res .put ("PictureDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_PICTURES ).getAbsolutePath ());
257- res .put ("MusicDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_MUSIC ).getAbsolutePath ());
258- res .put ("DownloadDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS ).getAbsolutePath ());
259- res .put ("MovieDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_MOVIES ).getAbsolutePath ());
260- res .put ("RingtoneDir" , Environment . getExternalStoragePublicDirectory (Environment .DIRECTORY_RINGTONES ).getAbsolutePath ());
255+ res .put ("DCIMDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_DCIM ).getAbsolutePath ());
256+ res .put ("PictureDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_PICTURES ).getAbsolutePath ());
257+ res .put ("MusicDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_MUSIC ).getAbsolutePath ());
258+ res .put ("DownloadDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_DOWNLOADS ).getAbsolutePath ());
259+ res .put ("MovieDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_MOVIES ).getAbsolutePath ());
260+ res .put ("RingtoneDir" , ctx . getExternalFilesDir (Environment .DIRECTORY_RINGTONES ).getAbsolutePath ());
261261 String state ;
262262 state = Environment .getExternalStorageState ();
263263 if (state .equals (Environment .MEDIA_MOUNTED )) {
264- res .put ("SDCardDir" , Environment . getExternalStorageDirectory ( ).getAbsolutePath ());
264+ res .put ("SDCardDir" , ctx . getExternalFilesDir ( null ).getAbsolutePath ());
265265
266266 File externalDirectory = ctx .getExternalFilesDir (null );
267267
@@ -276,9 +276,9 @@ static Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
276276 return res ;
277277 }
278278
279- static public void getSDCardDir (Promise promise ) {
279+ static public void getSDCardDir (ReactApplicationContext ctx , Promise promise ) {
280280 if (Environment .getExternalStorageState ().equals (Environment .MEDIA_MOUNTED )) {
281- promise .resolve (Environment . getExternalStorageDirectory ( ).getAbsolutePath ());
281+ promise .resolve (ctx . getExternalFilesDir ( null ).getAbsolutePath ());
282282 } else {
283283 promise .reject ("RNFetchBlob.getSDCardDir" , "External storage not mounted" );
284284 }
@@ -986,13 +986,13 @@ static void createFileASCII(String path, ReadableArray data, Promise promise) {
986986 }
987987 }
988988
989- static void df (Callback callback ) {
990- StatFs stat = new StatFs (Environment . getDataDirectory ().getPath ());
989+ static void df (Callback callback , ReactApplicationContext ctx ) {
990+ StatFs stat = new StatFs (ctx . getFilesDir ().getPath ());
991991 WritableMap args = Arguments .createMap ();
992992 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR2 ) {
993993 args .putString ("internal_free" , String .valueOf (stat .getFreeBytes ()));
994994 args .putString ("internal_total" , String .valueOf (stat .getTotalBytes ()));
995- StatFs statEx = new StatFs (Environment . getExternalStorageDirectory ( ).getPath ());
995+ StatFs statEx = new StatFs (ctx . getExternalFilesDir ( null ).getPath ());
996996 args .putString ("external_free" , String .valueOf (statEx .getFreeBytes ()));
997997 args .putString ("external_total" , String .valueOf (statEx .getTotalBytes ()));
998998
0 commit comments