I am copying an existing database
However it appears that the table is being accessed before the database is copied (if I repeatedly reinstall the database copies). The following is in the MainPage.
Interestingly I can get a Windows Phone 8.1 variant to work, but not for Windows 8.1
private async Task CopyDatabase()
{
bool isDatabaseExisting = false;
try
{
StorageFile storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync("pmquestionsoct2014dt.sqlite");
isDatabaseExisting = true;
System.Diagnostics.Debug.WriteLine("DB exists");
}
catch
{
isDatabaseExisting = false;
System.Diagnostics.Debug.WriteLine("DB doesn't exist");
}
if (!isDatabaseExisting)
{
var databaseFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/pmquestionsoct2014dt.sqlite"));
await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder, "pmquestionsoct2014dt.sqlite", NameCollisionOption.ReplaceExisting);
System.Diagnostics.Debug.WriteLine("DB copied");
}
Aucun commentaire:
Enregistrer un commentaire