Skip to content

Instantly share code, notes, and snippets.

@pille72 pille72/MainPage.xaml.cs
Last active Aug 29, 2015

Embed
What would you like to do?
SetUp
namespace com.example.hello
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
this.CordovaView.Loaded += CordovaView_Loaded;
}
private async void CordovaView_Loaded(object sender, RoutedEventArgs e)
{
await CopyDatabase();
this.CordovaView.Loaded -= CordovaView_Loaded;
}
private async Task CopyDatabase()
{
bool isDatabaseExisting = false;
try
{
StorageFile storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync("my.db");
isDatabaseExisting = true;
}
catch
{
isDatabaseExisting = false;
}
if (!isDatabaseExisting)
{
StorageFile databaseFile = await Package.Current.InstalledLocation.GetFileAsync("my.db");
await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder);
}
}
}
}
Here is a screenshot of the ".db"-File and of course the "Exception" which was thrown in the console
http://imgur.com/eKWjMjS
Of course I changed the Database-attributes from Build "Content" to "Resource" but it didn't worked.
"Immer kopieren" means "Always copy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.