how to autosave your game?

im making a mobile game for andriod and i want to make a autosave system. i made a save system before but that was when you press a but that it saves but not an autosaver. like when you press your home button that it saves your game and when you start it again you still have your progress you had before you closed your game.

If you already know how to save and load, then making the save occur when they exit the game is pretty easy.

There is a method that will be called when the the user tries to quit the game.

void OnApplicationQuit()
{
  //Call your save routine here
}

This will run when the application is about to quit. Assuming that they quit the application, and don’t just terminate it. To account for this, you could also call the save routine every couple of minutes, assuming your save routine runs quickly enough that the player wont notice it.

In the start method of a script in the game scene, you could check if a saved game exists and load it from there.

Hope this helps,
-Larry