I am working to develop an android APP with cordova,I wanted to create an folder everyday and store a txt file in it. everything I tried is working for the internal memory of each android but not for the External SD card, have a look and help me out,
if(sDeviceVersion=='4.0' || sDeviceVersion=='4.0.4'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion=='4.1' || sDeviceVersion=='4.1.2' ||sDeviceVersion=='4.3.1'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion=='4.4' || sDeviceVersion=='4.4.4'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion=='5.0' || sDeviceVersion=='5.1.1'){ var sPath = 'file:///mnt/sdcard/'; // }else if(sDeviceVersion=='6.0' || sDeviceVersion=='6.0.1'){ var sPath = 'file:///storage/sdcard1/'; }else if(sDeviceVersion=='7.0' || sDeviceVersion=='7.1.2'){ var sPath = 'file:///storage/sdcard1/'; }
Above condition is working till 4.4.4 version, after 5.0 the PATH is not correct.
I have tried all these below paths for /mnt and /storage
// sdcard0 works on all the androind for Internal Memory
// 'file:///storage/sdcard1/'; suppose to work for external in higher version but
// 'file:///mnt/sdcard/'; it works but in Internal memory ERROR
// externalSdCard -----> Not found with mnt and storage
// SECONDARY_STORAGE
// 'file:///storage/UsbDriveB/' -----------> didn't worked
// external_sd is not worked with storage and mnt
I read everywhere that sdcard0 is Internal and sdcard1 is an External, but it doesn't seems to be working anymore. can anybody help me with the Path.
Even I have tried
alert(cordova.file.externalRootDirectory); // file:///storage/sdcard0/ Internal memory alert(cordova.file.externalApplicationStorageDirectory); // path to file:///android/data... alert(cordova.file.dataDirectory); // file:///data/androind/data/... alert(cordova.file.externalDataDirectory); // file://storage/sdcard0/android/data/...
all above is working for Internal storage only.
All the permission for STORAGE/READ/WRITE to external storage is given.