Hello, I am trying to load and access a pre-loaded SQLite database and tried using logic to retrieve from the resources\raw folder. I'm using the Xamarin IDE and have looked at the examples within Xamarin. My question is in the statement below: var s = Activity.Resources.OpenRawResource(resource.raw.BackRoads);
The database is in this location - resources\raw\BackRoads.sqlite
When I try to build the code, it gives me an error on the OpenRawResource(resource.raw.BackRoads) statement, where it doesn't know what the resource.raw.BackRoads is. What location do I use? Is this correct?
Thanks, Mike
Code snippet below:
public void CreateDatabase(string sDatabaseName)
{
try
{
sMessage = "";
string sLocation = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string sDB = Path.Combine(sLocation, sDatabaseName);
if (!System.IO.File.Exists(sDB)) {
var s = Activity.Resources.OpenRawResource(resource.raw.BackRoads);
FileStream writeStream = new FileStream(sDB, FileMode.OpenOrCreate, FileAccess.Write);
ReadWriteStream(s, writeStream);
}
}
catch (SQLiteException ex)
{
sMessage = ex.Message;
}
}