Where is the app Personal Folder path

2019-01-29 12:40发布

Im trying to create a sqlLite db. This code works and create the db and allow me do insert and select.

string dbPath = Path.Combine(
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), 
                                 "ormdemo.db3");

//dbPath = "/storage/emulated/0/DCIM/ormdemo.db3";

var db = new SQLiteConnection(dbPath);
db.CreateTable<Stock>();

Right now the dbPath returned is:

"/data/user/0/MyFirstGPSApp.MyFirstGPSApp/files/ormdemo.db3"

But when I use a sqlLite Manager to try open the db I cant find the folder /data/user

Where is that folder /data/user?

The sqlLite have the option to open "APP" databases, but when try to select MyFirstGPSApp say need a root device.

The starting folder for sqlLite is /storage/emulated/0 and have a sub folder /DCIM

So I try to use a folder I can see ... like /storage/emulated/0/DCIM/ormdemo.db3 but then the new SQLiteConnection(dbPath) give me this error.

SQLite.SQLiteException: Could not open database file: /storage/emulated/0/DCIM/ormdemo.db3 (CannotOpen)

Do I need special permision to write in /DCIM folder?

2条回答
虎瘦雄心在
2楼-- · 2019-01-29 13:08

You can't see directly from mobile without root permissions. Try using Android Studio's File explorer feature.

查看更多
唯我独甜
3楼-- · 2019-01-29 13:14

Ok, there are three questions in your post. Before answer your questions, I think some pictures are necessary.

P1: enter image description here

P2: enter image description here

Like @Yogesh Paliyal has said, you need File Explorer to see it. If you also want to see it and you don't want to root you device, please follow me: Visual Studio->Tools->Android->Android Device Monitor->select one simulator from Devices column->File Explorer. I suggest you create a simulator which Api is below 21, because the higher also can't see the file. I am using 19 to see the files.

And I think you should read this firstly.


Ok, let's see your questions:

Where is the app Personal Folder path?

In android, there are two folder: personal/internal folder and public/external folder, here is official document.

Personal/Internal Folder path:

Public/External Folder path:

Where is that folder /data/user?

From P1, you can see the ->/data/data/ is behind of /data/user/0, so the folder /data/user/0/MyFirstGPSApp.MyFirstGPSApp/files/ormdemo.db3 is /data/data/MyFirstGPSApp.MyFirstGPSApp/files/ormdemo.db3 actually.

Do I need special permision to write in /DCIM folder?

Personal/Internal folder doesn't need permission, public/external folder need permission.

In /storage/sdcard folder, only Android folder is personal/internal folder, so you need permission:<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> or <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> or both.

查看更多
登录 后发表回答