c# - sqlite - database synchro/bakup - windows 10 mobile -


i'm making windows 10 apllication - sales manager. 3 tables. have local sqlite database. i'm looking easy way backup database or synchronize. because databae small think full synchro always, example: i'm clicking 'send database' , full data device send server. when click 'download' database downloaded. grateful advice way save database

imho, can take advantage of onedrive's app folder backup sqlite database.

the app folder dedicated, special folder app. app folder typically named after app, , found in apps folder in user's onedrive. if request onedrive.appfolder permission scope , user authorizes it, app gets read , write access folder.

and c#, can use onedrive sdk csharp in application. example, can send database file following:

private async task<item> uploaddbfile() {     storagefile dbfile = await applicationdata.current.localfolder.getfileasync("db.sqlite");      var onedriveclient = await onedriveclientextensions.getauthenticateduniversalclient(new[] { "onedrive.appfolder" });      using (var contentstream = await dbfile.openstreamforreadasync())     {         return await onedriveclient.drive.special.approot.itemwithpath("backup.sqlite").content.request().putasync<item>(contentstream);     } } 

and download db like:

private async task downloaddbfile() {     var onedriveclient = await onedriveclientextensions.getauthenticateduniversalclient(new[] { "onedrive.appfolder" });      using (var contentstream = await onedriveclient.drive.special.approot.itemwithpath("backup.sqlite").content.request().getasync())     {         storagefile downloadedfile = await applicationdata.current.localfolder.createfileasync("downloadeddb.sqlite", creationcollisionoption.replaceexisting);         using (var writerstream = await downloadedfile.openstreamforwriteasync())         {             contentstream.copyto(writerstream);         }     }; } 

please note use onedrive api in application, need first register application onedrive following these steps.

to sync local database, can try offline data sync in azure mobile apps. more powerful backup database.

when app in offline mode, users can still create , modify data, saved local store. when app online, can synchronize local changes azure mobile app backend. feature includes support detecting conflicts when same record changed on both client , backend. conflicts can handled either on server or client.

offline sync has number of benefits:

  • improve app responsiveness caching server data locally on device
  • create robust apps remain useful when there network issues
  • allow end-users create , modify data when there no network access, supporting scenarios little or no connectivity
  • sync data across multiple devices , detect conflicts when same record modified 2 devices
  • limit network use on high-latency or metered networks

for more info, please refer offline data sync in azure mobile apps, enable offline sync windows app, , todo offline sample in github.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -