I’m working on a simple text adventure for Android and have finished the navigational and encounter logic.
How would I go about saving data like player character stats, and player character inventory items?
For example, say the user’s character finds a magic sword. How would I save this so the player can see it in their inventory?
Thanks
I would recommend using the DB. See this link for a tutorial on using SQLite with Android.
As for the structure, you might want something like an Item table, with columns such as item_id, item_type (ie. weapon, armor, etc.), item_description, item_name, etc. You could put all your items into this table.
Create a character atable with columns such as character_id, name, etc. Every new character gets placed into this table. You would probably store things like stats here also.
As for inventory, you might not need a table to represent the inventory as a whole. Perhaps just an inventory_item table which basically links items (from Item table) to a character (from character table).
Edit: Reason for using a DB: You potentially have a lot of structured data. A majority of this data probably won’t be needed all the time. You may not want all of that just sitting around in memory. You could go the route of storing to a file, but a DB is much more flexible and easier to use for more complex data structures. Also, once you have the DB worked out, you could put an abstraction layer over it so you aren’t dealing directly with the DB.