android.gameengine.icadroids.persistence
Class GamePersistence

java.lang.Object
  extended by android.gameengine.icadroids.persistence.GamePersistence

public class GamePersistence
extends java.lang.Object

Class for user persistence. With this Class you can save Strings in a File to your internal storage. Both real devices and emulators can use the internal storage. You can use the game persistance for example to save variables or, highscores. You are allowed to use multiple game persistances, each additional persistance saves an additional file on your system if the filename name is different.

Author:
Roel

Constructor Summary
GamePersistence(java.lang.String filename)
          The constructor allows you to specify the filename the internal storage will use.
 
Method Summary
 java.lang.String loadData()
          Returns the full data (in String format) that is stored in the file.
 void saveData(java.lang.String data)
          Saves the data to the earlier specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GamePersistence

public GamePersistence(java.lang.String filename)
The constructor allows you to specify the filename the internal storage will use.

Parameters:
filename - The name of the file that will be used for this persistance.
Method Detail

saveData

public void saveData(java.lang.String data)
Saves the data to the earlier specified file. All previous saved data will be overwritten. You can get your previous data by loading it first and then appending your new data to the String.

Parameters:
data - The data that should be saved to the file, the data must be one entire String.

loadData

public java.lang.String loadData()
Returns the full data (in String format) that is stored in the file. This function will return the data or an empty String if the file does not exist, or the file is empty.

Returns:
String The data saved earlier.