Storing information on my app

Hey,

My app is quite finished, but I plan to sell uses as in-app purchases. It’s like a fingerscan.

How do I save how many times the user scanned his finger in the app’s permanent data? [import]uid: 95495 topic_id: 21121 reply_id: 321121[/import]

You basically have to create a file in your system.DocumentsDirectory on first run that you will read from/save to on subsequent starts and finger scans.

Basically the logic is something like:

Try to open the file
if that fails, create the file and initialize it to zero
if it succeeds, read in the value and store it in a Lua variable.
close the file.
Later when the user does a finger scan:

Increment the variable with the scan count.
Open the file
write the value to the file
close the file.

This is a very common development pattern. There are tons of examples in the API documentation on how to open, read and write files. There are tons of examples in the community created code as well.

Now you put out the word “Permanent”. When a user upgrades an app, it preserves the data in the system.DocumentsDirectory folder. But if they delete the app and re-install it, that data is deleted too. So you need to be aware that no data on a mobile device can be considered permanent.

Apple’s in-app purchases supports a call which you should make at the beginning to retrieve what the user has purchased before so you can set the app’s state back to what it should be based on their actual purchases. You could also store the data on an internet server and have your own “restore” code that you connect to on start up, fetch the count for that user so that if they delete the app you still have a record of it. The draw back there is they have to have net connectivity, you have to have a server that can deal with the potential load and the user should have a right to delete that data at some point.
[import]uid: 19626 topic_id: 21121 reply_id: 83535[/import]

http://techority.com/2011/12/28/ego-easy-saving-and-loading-in-your-corona-apps/

diginutscorp@gamil.com
twitter @diginutscorp

[import]uid: 40990 topic_id: 21121 reply_id: 83536[/import]