Android: Trying to reset save data on device when pushing a new build!

Hi, all!

So I’m working on an Android project with some basic progression information being saved between game instances. To accomplish this, I’m reading and writing to a save file at Application.persistentDataPath, and serializing / deserializing a custom savedata class.

All the save/load functionality works fine on my test devices – data persists as expected when I quit and reopen the app. **The problem is, ** when I push new builds to a device that’s already run the program before, the save data from that older build is not being reset, causing some big problems with my ability to test. Even though it’s a fresh build, all my progression information from a previous build is surviving!

So my question is – how can I reset the file saved at Application.persistentDataPath on an Android device whenever I push a new build? I’ll say that in a perfect world, I’d like to generally be able to access the Application.persistentDataPath from the Unity editor (on Windows), so as to be able to generate and push “Dummy” saves – but the base-level goal is just being able to reset the device’s save data with each build.

I’m not sure if this is necessary for my question, but just in case, here’s the save / load code I’m using:

    public static void Save(SAVEDATA_CLASS saveData)
    {
        if (saveData != null)
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Open(Application.persistentDataPath + saveFileName, FileMode.OpenOrCreate);

            bf.Serialize(file, saveData);
            file.Close();
        }
    }
    public static SAVEDATA_CLASS Load()
    {
        SAVEDATA_CLASS output;
        if (File.Exists(Application.persistentDataPath + saveFileName)) {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Open(Application.persistentDataPath + saveFileName, FileMode.Open);
            output = (SAVEDATA_CLASS)bf.Deserialize(file);
            file.Close();
        }
        else {
            output = new SAVEDATA_CLASS();
        }
        return output;
    }

try something like this.

private const int version = "2";

bool thisIsADifferentVersion() {
	int previousVersion = PlayerPrefs.getInt("appVersion", version);
	return previousVersion != version;
}

void checkAndHandleNewVersion() {
	if (thisIsADifferentVersion()) {
		// reset stuff
		PlayerPrefs.setInt("appVersion", version);
	}
}

… then with each release, bump the value of “version”.