Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

android - Where is the app Personal Folder path

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...