I have a problem with deleting created files on my sdcard. I looked everywhere, but cant find anything to solve my issue.
I created a xml file in a folder on my sdcard. this works fine. but when I switch to the next level, I want to delete that file and overwrite it with the new just created xml file. it works without any problems in the editor, but when I test this on my desire z, the old file isn’t deleted so the new file will not be created under the same name.
I also tried to delete the folder on exit where I save the file, but this also only works in the editor. Do I need another permission entry in the manifest to delete files and folders or what do I miss?
I already inserted the android.permission.WRITE_EXTERNAL_STORAGE into my manifest. Creating files with the data is working fine.
When I first start, a new file is created onto my sdcard in the specified folder. The problem is, that I can’t delete that created file or directory.
Exactly. Ill throw an exception and when deleting fails I show a label that the file wasnt deleted. I also checked with a file browser if the file is still there. And as I mentioned earlier, creating the file, directory works fine when I test it with the editor and with my htc phone. Deleting files and directories only works inside the editor.
I now create a new different named file for every new level as a workaround. But this is not a good solution.
I have the same problem on my end. I’m working on an application for a Android tablet and i made the same steps as DannyDan. Force SD_Card permission is on and it’s all fine in the editor. I first check if the file exists and if it does i first delete it (…) and then Create it. Doesn’t work on Android. I’m using Application.persistentDataPath for my storage. When i press my Load button it load’s my first saved file and if i save my file it doesn’t overwrite the old one.
I changed my code and deleted the if statement to check if the file is already there and now its really working just fine.
Thanks for the tip, Ultimatemau.