I already know how to persist normal data throughout Android activities, but I’m wondering if the same methods are safe to use for Android purchase data.
I’m making a free app that uses in-app purchases to unlock all the content. This is something that I’m currently checking in the splash screen activity in order to customize the UI, however I would also need this information throughout the app.
Is it best to query in each activity, or is a Shared Pref safe enough?
As a note, I’m using v3 of Android’ billing library.
Thanks
Shared Preferences are OK for this. Your data is sandboxed the same as if it were a database. (Security-wise, both are just as safe)
You will need to query either the database, or SharedPreferences to get this data in your Activity regardless. Doesn’t really matter from which data store you retrieve it.
You don’t have to worry about users changing your data (somehow changing their local status to ‘paid’) as they aren’t able to change your SharedPrefs (or database values) – since they don’t have access to these secure data stores.