BackUp sqlite db from UWP application to one drive

I have a UWP application and want to backup the database on a single drive. In fact, I am using sqlite for UWP with EF7 RC1.

All I want is a copy from my database in OneDrive to sync it between devices, but I'm completely lost. I can not find the database on my win10 mobile device.

What is a .db location on my W10 mobile device? Which one is the best OneDrive API for W10? Is there a sample where I can read some information?

+5
source share
1 answer

Your database should be in your local storage application.

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

Open the file explorer, go to the folder C: \ Users \ username \ AppData \ Local \ Packages. (Remember to replace the username with your real username. Then find the folder containing your package name.

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

LocalStorage example

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

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

If your database was created before deploying your application, your database will be deployed to the application installation folder: to find it, use var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;

For the OneDrive API you have examples:

+1
source

Source: https://habr.com/ru/post/1246744/


All Articles