locked
BackUp Data stored in a MetroStyle App

    Question

  • I decided to build a Metro Style App for Windows 8 and I'm rarely new to it. I'm familar with coding in JavaScript and HTML.

    There is a large amount of data to be stored in my app. The user has have the possibility to add and remove data as well. I found out, that I have to use IndexedDB to save all the data within my app.

    My question: Is there any possibility to backup and restore the data saved within the app? I think there has to be an easy way to restore the data in Terms of a System Crash or something, isn't it? Additionally it would be cool, if it were possible to use the stored data on different machines.

    Thank you very much for your answers!

    Dragon, Germany

    Saturday, March 3, 2012 9:55 AM

Answers

  • The best example is the File Access Sample. You'll learn how to create/write/read and delete files.

    Next, in the package.appxmanifest file, you need to set some very important information. you'll need to set the Capabilities for Documents Library Access. In Declarations, add a file type association, enter in the DisplayName and InfoTip for rollover effects, enter in your own created .filetype "example with mine is .flib" in the Name field and in your supported file type. And if I remember right, point your file type icon to the small 30x30 in the Application UI settings.

    Since you'll be writing "data" to the file, it's really upto you what and how you store the data. For me, I use raw data via JSON data arrays in a proprietary format for my app, to keep prying eyes from reading and changing, but that's a whole different subject. I'm sure someone here has been able to store images/music this way as well.

    Sunday, March 4, 2012 6:43 AM

All replies

  • just use the WriteFileAsync functions. You'll see an example on the samples page for "writing data". In my apps, I give the option to "backup" data as well. I just send it to the Documents folder. Then create an icon that is associated with my app, so if the user clicks on the backup data file it will also launch the app.

    Of course I also give the option to "restore" the backup data.

    You'll find your answer in the the samples.

    Saturday, March 3, 2012 4:15 PM
  • Thanks for your fast answer. I was a little bit frightend, that it isn't possible to create backup files with JavaScript...I studied the "Reading and writing data sample", but I can't find any reference to a file or folder within the program.js. Perhaps I havn't got the sample file you mean? Do you have a link to the app you are speaking of? What you discribe sounds perfect: Backup, send to documents folder, restore from documents folder. 

    But I have two more questions: Is it possible to create my own, app-specific file extension? Is it possible to store more than plain text? Images for example?

    Thank you very much!!!

    Saturday, March 3, 2012 9:36 PM
  • The best example is the File Access Sample. You'll learn how to create/write/read and delete files.

    Next, in the package.appxmanifest file, you need to set some very important information. you'll need to set the Capabilities for Documents Library Access. In Declarations, add a file type association, enter in the DisplayName and InfoTip for rollover effects, enter in your own created .filetype "example with mine is .flib" in the Name field and in your supported file type. And if I remember right, point your file type icon to the small 30x30 in the Application UI settings.

    Since you'll be writing "data" to the file, it's really upto you what and how you store the data. For me, I use raw data via JSON data arrays in a proprietary format for my app, to keep prying eyes from reading and changing, but that's a whole different subject. I'm sure someone here has been able to store images/music this way as well.

    Sunday, March 4, 2012 6:43 AM
  • WOW...that's great!! Thank you very much. Now I understand the fileaccess sample! I think that's the way it has to be done. I'm only familiar with webdesign in JavaScript, HTML and CSS. Programming Apps is comletly new for me. Now I only have to find a way to store my database-containers. But to try this out I would have to write a sample Database.

    Thanks a lot!

     
    Sunday, March 4, 2012 9:39 AM