Closed eugenioestrada closed 10 years ago
Hi, I'm sorry but I have no experience with Windows Phone apps, I don't have any idea why could be. @ncipollina @micahl @vladstoick Do you guys have any ideas?
Thanks you @oysteinkrog! Now my app is working with an xap signed for the Windows Phone Store. Part of the problem was the described on the developers.nokia.com site. (The database file has to be added to the project as content and has to be copied to the Isolated Storage.
StorageFile dbFile = null;
try
{
// Try to get the
dbFile = await StorageFile.GetFileFromPathAsync("PATH");
}
catch (FileNotFoundException)
{
if (dbFile == null)
{
IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
using (Stream input = Application.GetResourceStream(new Uri("ASSEMBLY;component/FILENAME", UriKind.Relative)).Stream)
{
using (IsolatedStorageFileStream output = iso.CreateFile("PATH"))
{
byte[] readBuffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = input.Read(readBuffer, 0, readBuffer.Length)) > 0)
{
output.Write(readBuffer, 0, bytesRead);
}
}
}
}
}
It can be done it the Application_Launching of the App.xaml.cs file.
The other problem is that only a filename not works in Windows Phone and you should use a path like that:
string path = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "cache.sqlite"));
I think that you can add that to the documentation, because it's not clear.
Ah, good to hear you got it working. I'll update the readme:)
Had some similar problems and documented them on my blog... Maybe the pre compiler part could be looked at for the readme too? http://depblog.weblogs.us/2015/01/06/sqlite-net-and-sqlite-net-extensions-with-universal-apps/
Hmm that blog posts seems to confuse the original sqlite-net project and this fork. I created this fork for PCL support and I've ended up incorporating lots of fixes and features. What makes everything even more confusing is that the original project also has PCL support now! :P I've never done much WP development and I've barely event tested that code, it's primarily from contributors. If anyone has some suggestions for improvements in the readme please send a pull request!
@oysteinkrog Should we use the same tutorial: http://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020
Hi, I've published an app as a Beta and the app cannot create the database file (in debug mode it works). It seams to be something similar to the exposed in this link: http://developer.nokia.com/community/wiki/How_to_use_SQLite_in_Windows_Phone.
I've tried to copy the database file to included it as content, but I don't find where the file is being created.
The unsigned app works correctly.