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?
You can't see directly from mobile without root permissions. Try using Android Studio's File explorer feature.
Ok, there are three questions in your post. Before answer your questions, I think some pictures are necessary.
P1:
P2:
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:
In android, there are two folder: personal/internal folder and public/external folder, here is official document.
Personal/Internal Folder path:
/data/data/package name/shared_prefs: SharedPreferences
/data/data/package name/databases: Sqlite
/data/data/package name/files: Api:getFilesDir()
/data/data/package name/cache: Api:getCacheDir()
/storage/sdcard/Android/data/package name/files: Api:getExternalFilesDir()
/storage/sdcard/Android/data/package name/cache: Api:getExternalCacheDir()
Public/External Folder path:
/storage/sdcard
folder, onlyAndroid
folder is personal/internal folder,so/storage/sdcard/DCIM
,/storage/sdcard/Music
,etc, all of them are public/external folder: Api:Environment.getExternalStoragePublicDirectory(String type)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.Personal/Internal folder doesn't need permission, public/external folder need permission.
In
/storage/sdcard
folder, onlyAndroid
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.