Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BackUp sqlite db from UWP app to One drive

I have an UWP app and want to backup it's database to One drive actually I'm using sqlite for UWP with EF7 RC1.

All I want is a copy from my database to OneDrive to sync it between devices but i'm totally lost, Can't find the database on my win10 mobile.

What is the .db location on my W10 mobile? Wich one is the best OneDrive API's for W10 ? There is a sample where i can read some info ?

like image 320
Juan Pablo Gomez Avatar asked Apr 08 '16 22:04

Juan Pablo Gomez


1 Answers

Your database should be in your application local storage.

On desktop, to find it, In Visual Studio, open your Package.appxmanifest file, open the Packaging tab and copy the package name.

Open your file explorer, navigate to the folder C:\Users\userName\AppData\Local\Packages. (don't forget to replace userName by your real user name. Then search for folder containing your package name.

If you open the folder LocalState you should find your database file.

LocalStorage sample

To access it through code (will work on phone also):

var folder = ApplicationData.Current.LocalFolder;
var files = await folder.GetFilesAsync();
var dbFile = files.FirstOrDefault(x => x.Name == "myDatabase.db");

If your database is created before your application deployment, your database will be deployed in your application install folder: to find it use var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;

For OneDrive API, you have some samples there:

  • https://github.com/OneDrive/onedrive-sdk-csharp/tree/master/samples/OneDriveApiBrowser
  • https://github.com/OneDrive/onedrive-sdk-csharp/tree/master/samples/OneDrivePhotoBrowser
like image 87
Arnaud Develay Avatar answered Sep 21 '22 15:09

Arnaud Develay