I am looking at persistent data storage solutions and came across GGData. Thanks for all the hardwork that went into this library. My quick question is whether there are any ‘gotchas’ in regards to pre-populating a GGData box and supplying this file to my app in my project directory. Think about a small library that I want the app to have access to on first run. I can see the file GGData creates in my DocumentsDirectory when I create a new box. Is it as simple as including this file in my project build directory and then copying it to the DocumentsDirectory from the ResourceDirectory where it gets copied by the app? Thanks for your help.
If you copy it across yourself it should be fine. As far as I can remember we didn’t allow for loading boxes from the Resource directory simply because you can’t write to it.
There is also the setIfNew function that allows you to set default values if there isn’t a value already. I suspect though that yea if you have a lot of values to set it might be easier to just create the file manually yourself like you said and then just include it in the build and copy it over on first run. Although this scenario was never tested I can’t think of any reason off the top of my head why this would cause problems.
Thank you very much for chiming in. I will test this and let you know how it goes. It could make a good option for some configuration data supplied with an initial build which might from time to time get updated and made available for download etc.
How about if you call GGData:new() with a path and baseDirectory it will load that box up and populate the data, then if you call save() it will save it out to the DocumentsDirectory ?
Super. Great idea. Will try.
Let me know how it goes!
Hi!
Could you please take a look at my post? Thanks!
http://forums.coronalabs.com/topic/43803-ggdata-help/?hl=ggdata
If you copy it across yourself it should be fine. As far as I can remember we didn’t allow for loading boxes from the Resource directory simply because you can’t write to it.
There is also the setIfNew function that allows you to set default values if there isn’t a value already. I suspect though that yea if you have a lot of values to set it might be easier to just create the file manually yourself like you said and then just include it in the build and copy it over on first run. Although this scenario was never tested I can’t think of any reason off the top of my head why this would cause problems.
Thank you very much for chiming in. I will test this and let you know how it goes. It could make a good option for some configuration data supplied with an initial build which might from time to time get updated and made available for download etc.
How about if you call GGData:new() with a path and baseDirectory it will load that box up and populate the data, then if you call save() it will save it out to the DocumentsDirectory ?
Super. Great idea. Will try.
Let me know how it goes!
Hi!
Could you please take a look at my post? Thanks!
http://forums.coronalabs.com/topic/43803-ggdata-help/?hl=ggdata