582348 (2) [Avatar] Offline
#1
I am using below code to retrieve Sqlite3 file as has been mentioned in book.

            var local = FileSystem.Current.LocalStorage.Path;
            var datafile = PortablePath.Combine(local, "counters.db3");
            connection = new SQLiteAsyncConnection(datafile);
            connection.GetConnection();


I realized that code is looking for database at "C:\Users\<User>\AppData\Local\Microsoft.TestHost.x86\15.6.2\". For testing Model, ModelView that helped but I wanted to know what is right place to put this file so I can test in Android and iPhone emulators?
Jim Bennett (88) [Avatar] Offline
#2
The value that comes back for
FileSystem.Current.LocalStorage.Path
will be right for the different platforms, so you shouldn't need to do anything different on Android or iOS - when you run this code on an emulator, simulator or physical device it will return the correct path for that emulator/simulator/device.
582348 (2) [Avatar] Offline
#3
What I am trying to do is add one more database. I have created content for that database. In the app, I want to read it (Textbook example creates the database and then reads from it. I already have database and just need to read it). So I want to know where to place this database and how to read it. Right now, I have put that database at Countr.Core/Models/MyOwn.db3
Jim Bennett (88) [Avatar] Offline
#4
A great article on it is here:

https://robgibbens.com/deploying-a-database-file-with-a-xamarin-forms-app/

It comes from Rob Gibbens, a Xamarin University instructor so he knows his stuff!