Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Storing Local Data

edited June 2012 in Questions Posts: 2,211

Hi All,

Could someone please describe to me how you can save local data. I have a few questions:

  1. Do you have control over the data saved or is it all variables/arrays/matrix's etc from an application when running?
  2. Can you access the data from more than one application?
  3. How do you clear data out if necessary?

That should do for starters - I'm sure that there will be other questions arising from this.

Thanks,

Bri_G

:)

Comments

  • Posts: 384

    Hi @Bri_G, check out the storage section of the online help, at the bottom. You can use saveLocalData() to save a string, and readLocalData() to get it back again. It gets stored in a plist file, which you could read with a computer program like iExplorer, but it would not be readable by another ipad app. You could use the global data function to share data between your own Codea projects. There is a clear function as well to get rid of whatever you have saved.

  • edited June 2012 Posts: 489

    My understanding is:

    1. saveLocalData(key, value) - a non-nil 'value' can only be a number, string or boolean (source: Persistence.m code in the Codea Runtime Library).

    2. Yes, by using GlobalData (not ProjectData or LocalData) (source: in-app reference).

    3. By using clearLocalData() or clearProjectData() (source: in-app reference) or setting the value of a key to nil (source: Persistence.m). See also this discussion.

Sign In or Register to comment.