User382
User382

Reputation: 874

Xamarin Android how to retrieve device database

I have created Sqlite database using

var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
pathToDatabase = Path.Combine(documents, databaseName);

using (var conn= new SQLite.SQLiteConnection(pathToDatabase))
{
            conn.CreateTable<SETTINGS> ();
            conn.CreateTable<USER> (); 
}

I want to see(using Sqlite Browser) the database created. How to access the database? I have tried through Xamarin Studio -> Tools -> Android Device Monitor. There is nothing like /data/data/app/databases/test.db

data folder doesn't show any contents. However, i am sure that the database is created as i can query and retrieve the data.

Upvotes: 1

Views: 3851

Answers (3)

Suchith
Suchith

Reputation: 1527

You can copy the DB file programmatically from device internal path to device Download folder and from there you can access it. For more details you can check by blog post here: http://www.appliedcodelog.com/2017/07/how-to-fetch-android-sqlite-db-file.html

Upvotes: 0

Jared
Jared

Reputation: 702

You can't access the database file on an actual device unless it's rooted. That file system access is restricted to prevent people from easily gaining access to the data of your application.

The examples you're seeing that are explaining how to access your database on the file system are assuming you're using an emulator.

Upvotes: 3

daniherculano
daniherculano

Reputation: 383

Your database is located at files folder from your app directory (e.g. "/data/data/ProjectName.ProjectName/files")

I suggest you take a look at the following link where you'll find the Monodroid environment variables

Upvotes: 0

Related Questions