Last active
August 29, 2015 13:57
-
-
Save pille72/9615840 to your computer and use it in GitHub Desktop.
SetUp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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