Mike Jablonski
Mike Jablonski

Reputation: 1755

How do you place an exisiting SQLite database into an application's local data store for use in a Universal Windows Platform application?

I have successfully followed the instructions to work with SQLite databases in a Universal Windows Platform application, as explained here: "Use a SQLite database in a UWP app"

That tutorial shows how to create a new SQLite database, with C# code, in the application's local data store, but it does not explain how to put an existing SQLite database into the local data store.

Upvotes: 0

Views: 189

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7727

how to put an existing SQLite database into the local data store.

The database is also a db file, so this question can be translated into how to copy file to local storage.

Here is the code:

public async Task<StorageFile> CopyFileToLocalStorage(StorageFile dbFile)
{
    var localFolder = ApplicationData.Current.LocalFolder;
    var localFile = await dbFile.CopyAsync(localFolder, "sqliteSample.db",NameCollisionOption.ReplaceExisting);
    return localFile;
}

Best regards.

Upvotes: 2

Related Questions