- Home /
How to delete game data from persistentDataPath?
(Android build) I keep some user data in files, saved at persistentDataPath. But after uninstalling app, these files are not removed. How to delete them? Maybe there are some settings?
Answer by upasnavig90 · Dec 27, 2018 at 05:47 AM
you can do one thing, set a playerpref int for in start of game, if game is opened first time after installing delete the files in persistent path and set playerpref to 1, otherwise skip the code.
code snippet:
class XYZ : Monobehaviour{
int firstTime=0;
void Start()
{
if(firstTime==0){
//delete and create new files in persistent data path
//https://answers.unity.com/questions/1175859/how-to-delete-a-file-
using-applicationdatapath.html
PlayerPrefs.SetInt("firstTime", 20);
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612184630im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Android, How can I permanently save data? (A couple variables) 4 Answers
How to Simulate a Fresh install Android. 1 Answer
Command-line build for Android strips out used assets like png 2 Answers
Why am i getting a NullReferenceException when i switch platform to Android? 0 Answers
How to export to gradle using BuildPipeline.BuildPlayer 2 Answers