Innova
Innova

Reputation: 396

Where is my sqlite db?

I've an app written in Xamarin.Forms to create a new sqlite db in my Android device. I use this code:

string dbPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
database = new SQLiteAsyncConnection(dbPath);
database.CreateTableAsync<TodoItem>().Wait();

The database is created correctly, but I cannot find it on specified path (in this case '/data/data/Todo.Android/files/TodoSQLite.db3')

I searched using File Explore, but nothing. So, where is located this file?

Upvotes: 0

Views: 1470

Answers (2)

Grace Feng
Grace Feng

Reputation: 16652

The database is created correctly, but I cannot find it on specified path (in this case '/data/data/Todo.Android/files/TodoSQLite.db3')

Just from your code, I didn't see you create or successfully connected to your TodoSQLite.db3 file, you just find the folder path where your db should be placed.

I don't know how you think your db is correctly created, but if you use Environment.SpecialFolder.Personal, then the path you trying to access is right, but since you couldn't find your db file, I can only imagine that you actually didn't create your db correctly.

You may code for example like this to create a db with file name "TodoSQLite.db3":

string dbPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
database = new SQLiteAsyncConnection(System.IO.Path.Combine (dbPath, "TodoSQLite.db3"));
database.CreateTableAsync<TodoItem>();

Upvotes: 3

Teras23
Teras23

Reputation: 1

Did you look for the file in the root directory?

The first data folder should be in the root directory (/) with folders like dev, etc and system. You might have searched for the folder in your phone storage directory (like /storage/emulated/0). As far as I know, you can only access the root directory with a rooted phone.

If you want to get the file:
You could try using a different file explorer but the app data is usually still hidden for non-rooted phones.

Or get the file using your computer.

Upvotes: 0

Related Questions