My app creates sqlite database which file path starts with "/data/data/". From what I can see, data is stored correctly. But when I try to find the file itself (with ES Explorer), I just can't! Even the path "/data/data/" doesn't exist. Where can it be?
You can find your database in
/data/data/your.application.package/databases/your_db_name
This is the default path to your database
You don't have permission to look at that folder in your file explorer. In an emulator the same happens in the Eclipse file explorer. You can however access this path in the debug mode.
It really is in /data/data/your.application.package/databases/dbname.db
/data/data/[your_package_name]/databases/[your_db_name].db
Related
I am making an app which use the following java line:
Net dnnNet = Dnn.readNetFromONNX("path\to\file");
As you can see, readNetFromONNX requires path to onnx file.
So I put my onnx file under assest folder, so I can use it at run time.
The problem is I you can only read assets foler with AssestManager and inputstream... the readNetFromONNX needs path...
How do I overcome this probelm? Is there a way to get the path of the file at run time? Maybe other folder?
Thanks from advance
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?
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:
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:
/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:
In /storage/sdcard folder, only Android 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)
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.
You can't see directly from mobile without root permissions.
Try using Android Studio's File explorer feature.
I'm trying to create a partition called "subdata" under "/data". But it's failing.
The steps I tried and the failure results are mentioned below.
File dir =new File(/data/subdata/");
boolean success = dir.mkdir();
Here, the "success" value is found "false".
File dir= context.getDir("/data/subdata",Context.MODE_WORLD_READABLE);
Here, I get "java.lang.IllegalArgumentException: File app_/data/subdata/ contains a path separator"
Please, help me in creating this subfolder under /data/ partition.
I solved my need in the below manner.
As I mentioned in the question that, if I create the sub folder manually, I'm able to read and write to that subfolder in the /data.
So, I created this subfolder through init.rc (as I mentioned, I have the build code also). As I'm more fluent in Linux than in Android, I fixed it through init.rc. Now I'm able to read/write to that folder through my android code.
I want to open my database file using "Questoid SQLite Manager". When I'm trying to do that a message says: "Select db file in File Explorer, and open it in SQLite Manager..."
As I've searched about this error, I've find that the database must have .db extension. now my database name is mydb.db and it's running on emulator.
Most of topics about this error are referring to .db extension and root permission as I've seen in these topics:
Not able to open database file in SQLite manager plugin for eclipse?
https://stackoverflow.com/questions/19177467/not-able-to-open-the-db-file-with-questoid-sqlite-manager-browser
Why I can't see DB structure by SQLite Manager in file explorer
What else I should do about it?
I had the same problem with "sqlitemanager": only .db-Database files are accepted.
This is the solution:
Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip
Unzip and put it into eclipse/dropins (not Plugins)
You can use http://sourceforge.net/projects/sqlitebrowser to open your database file.
did you try to open it using firefox.
there is a plugin needed for it to do so
check this
I wrote the following statement:
db.getPath();
and it returns the following value:
data/data/mypackagename/databasename/tablename
But in the file explorer I only get upto path data/data/. Everything from there onward is blank. My package is not listed. What can I do to fix this?
You do not have access on production hardware to examine those directories using DDMS' File Explorer or any other tool. Your code will be able to access getPath() just fine, though.