Here is the final solution after my research and testing in both Android and IOS devices.
Step1: Differentiate the file path based on plat form like below:
device.platform.toLowercase();
FileUtility.prototype.getFilepath = function(){
if(device.platform.toLowercase == "ios"){
return "gsmData.txt"; }
else if(device.platform.toLowercase == "android")
{ return
"Android/data/test.app.com/files/testData.txt"; } };
Above code will return "ios" or "android" based on device.
Step2: Create the file with the path which you get from above function
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
readFileSystem, failureCallBack);
function readFileSystem(fileSys){
fileSys.root.getFile(getFilepath(), {create: false,exclusive:false}, function(fileEntry){
fileEntry.remove(successCallBack,failureCallBack);
}, failureCallBack);
}
In IOS device, if you create the file with your APP then that file will be deleted automatically when you remove the APP from IOS device.
But in Android , created files will be deleted if you store them APP related folders like I have mentioned above.
Hope it helps :)