I am trying to figure out what order I need to do everything to have my program flow well and not crash. I want the player of my game to have a team of three people each as their own class with stats such as attack, health, etc.
- When the game is first installed and run, I want to have a sqlite db made and filled with the 3 starter characters.
- When they start it any other time, I want to have the three stored characters in the DB to be assigned to 3 local character objects.
I have a SQLite Adapter class handling the Db but I’m not sure how to order everything so that I check first to see if there is a Db in the programs Db path and open it if there is. Otherwise just create a new one and populate it with the initial characters.
I currently have:
DbAdapter = new PlayerDbAdapter(this);
DbAdapter.open();
DbAdapter.setInitialPlayers(); // inserts my initial player object info into the Db
which calls
public PlayerDbAdapter open() throws SQLException {
dbHelper = new SummonSQLiteHelper(context);
String s = DbPath + DB_NAME;
database = SQLiteDatabase.openOrCreateDatabase(s, null);
return this;
}
And now I’m a little lost as to what I need to make sure that I don’t overwrite any saved info in the Db with the initial values everytime I start the program. Any suggestions?
Try like this