Hi All,
how to install json file or database file when user install the application. The application is reading certain information from the file to be used.
Regards
Abdul
Hi All,
how to install json file or database file when user install the application. The application is reading certain information from the file to be used.
Regards
Abdul
Hi. I may have misunderstood your question, but it sounds like you want the user to get some pre-populated DB or JSON file as part of a clean app installation?
You can achieve this in a couple ways (at least):
Include the file in the app itself and then copy it to the documents folder for future use. You can’t write files in the resource directory (from a live app), but you can include files there, copy them to the documents folder and subsequently read and write to the ‘documents’ copies.
On first run have the app download the file(s) you need and write them to the documents folder. You’ll need to use your own server as a source or a 3rd party solution like Coronium, Parse, etc.
Hope this helps.
Thanks roamingger for you reply… i think option 1 is the best since it will be local and does not require internet. So this work by adding x.json file to project folder but how to save it locally then . which api should do that ?
thx
Abdul
I suggest the following:
Using Corona simulator, build a table containing data you want.
json encode it
Save it to a file.
Grab that file and place it in your game.
Load that copied file in your game
json decode the loaded file.
Bam! You have a table
My SSK library has table, io, and string extensions to make this a breeze, but there are other solutions out there.
https://github.com/roaminggamer/RG_FreeStuff/tree/master/SSK/RGExtensions
Grab it, install it, and then use the table extensions to do the work of saving and loading the JSON encoded table: https://github.com/roaminggamer/RG_FreeStuff/tree/master/SSK/RGExtensions#table-extensions
Thanks sir . I will play with that
Abdul
Hi. I may have misunderstood your question, but it sounds like you want the user to get some pre-populated DB or JSON file as part of a clean app installation?
You can achieve this in a couple ways (at least):
Include the file in the app itself and then copy it to the documents folder for future use. You can’t write files in the resource directory (from a live app), but you can include files there, copy them to the documents folder and subsequently read and write to the ‘documents’ copies.
On first run have the app download the file(s) you need and write them to the documents folder. You’ll need to use your own server as a source or a 3rd party solution like Coronium, Parse, etc.
Hope this helps.
Thanks roamingger for you reply… i think option 1 is the best since it will be local and does not require internet. So this work by adding x.json file to project folder but how to save it locally then . which api should do that ?
thx
Abdul
I suggest the following:
Using Corona simulator, build a table containing data you want.
json encode it
Save it to a file.
Grab that file and place it in your game.
Load that copied file in your game
json decode the loaded file.
Bam! You have a table
My SSK library has table, io, and string extensions to make this a breeze, but there are other solutions out there.
https://github.com/roaminggamer/RG_FreeStuff/tree/master/SSK/RGExtensions
Grab it, install it, and then use the table extensions to do the work of saving and loading the JSON encoded table: https://github.com/roaminggamer/RG_FreeStuff/tree/master/SSK/RGExtensions#table-extensions
Thanks sir . I will play with that
Abdul