Skip to content

Instantly share code, notes, and snippets.

@pille72
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pille72/9615840 to your computer and use it in GitHub Desktop.
Save pille72/9615840 to your computer and use it in GitHub Desktop.
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