Srabon Sajib
Srabon Sajib

Reputation: 11

Where is Created DB path and share single database in multiple project (Xamarin)

I am new in Xamarin and trying to make a simple project. I already make a small CRUD project with SQLite local database. I have two questions :

  1. In which folder (path) in my computer the database is created ? Below is my DB path. But I am unable to find my database in my computer (Actually I want to know the folder path where is database created)

     string DBPath=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "myDB.db3");
    
  2. My 2nd question is, I want to get data from same database (myDB.db3) from two different project. How can I do it using Xamarin?

I google a lot but do not get any proper answer. Please help.

Thanks in Advance.

Upvotes: 1

Views: 638

Answers (1)

Kay
Kay

Reputation: 13146

  1. Usually it is the home directory of the user (e.g. /Users/kay on macOS). Use Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); to see where the file is stored on which platform.
  2. Put the db file within a folder of your shared project. Then you can use *Add / Add Exisiting Item to link this file to your platform specific projects like MyApp.iOS/Resources or MyApp.Android/Assets.

Upvotes: 1

Related Questions