MD Amanullah Hoque
MD Amanullah Hoque

Reputation: 161

How to access xamarin Android environment.personal system folder?

I am just working with sqlite DB. My DB location is system.environmet.specialfolder.personal So how can access this folder

Upvotes: 0

Views: 743

Answers (1)

Frauke
Frauke

Reputation: 1582

Here's how you can create a connection to an SQLite DB located in System.Environment.SpecialFolder.Personal:

public class SQLite_Android : ISQLite
{
    public SQLiteConnection GetConnection()
    {
        string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        var path = Path.Combine(documentsPath, "mySQLite.db"); // change mySQLite.db for your SQLite db filename
        // Create the connection
        var conn = new SQLiteConnection(path);
        // Return the database connection
        return conn;
    }
}

With

public interface ISQLite
{
    SQLiteConnection GetConnection();
}

Upvotes: 1

Related Questions