Answered by:
How to find db file ?

Question
-
User366365 posted
Hello, I am working on Xamarin.forms. I am Using SQLite DB to store data. I am able to store data and get data from DB. Now I need to see that database file. How I can see that. I have installed Browse DB software. The path where it is storing DB is "/data/data/com.companyname.SQLite/files/Student.db3" But when browse file is not showing and checked by showing hidden files also. Please help me out
Wednesday, March 20, 2019 5:55 AM
Answers
-
User369979 posted
After analyzing your storing path, I find it is the MyDocument folder path. This is a private directory to your application so you won't be able to see these files using a file browser unless it has root privileges. You could try this https://stackoverflow.com/questions/26396105/specialfolder-personal-location/26396658#26396658 to find your file there.
- Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
Friday, March 22, 2019 8:36 AM
All replies
-
User383567 posted
Follow this path in your phone or tablet after ruuning the app
/data/data/com.companyname.SQLite/files/Student.db3
you can find the db
Wednesday, March 20, 2019 7:08 AM -
User366365 posted
@Sreedevi /data/data/com.companyname.SQLite/files in this path it is showing empty. When change settings to show hidden files it is showing few files (.dll,.pdb,.mdb files) but not Student.db3.
Wednesday, March 20, 2019 9:26 AM -
User369979 posted
If you can read data from this file path and you can't find the file there, try to copy this file to the path where you could find.
// Check if it exists at that path if (File.Exists(filePath)) { // Copy the file to the app's local folder string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string destinationPath = Path.Combine(folderPath, "myData.db"); File.Copy(filePath, destinationPath); }
Thursday, March 21, 2019 9:08 AM -
User366365 posted
hi, @LandLu thanks for your reply. Is that ok if I give file path like var filePath= Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName); I am new to this. please help me with this
Thursday, March 21, 2019 1:45 PM -
User369979 posted
@sagar Of course, you can. Refer to this documentation: https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.7.2 The My Documents folder. This member is equivalent to Personal. Personally, I prefer to use
MyDocuments
.Friday, March 22, 2019 2:24 AM -
User366365 posted
@LandLu after copying also in destination DB file not showing I am using the following code var dbName = "Student.db3"; var path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
if (File.Exists(path)) { string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string destinationPath = Path.Combine(folderPath, "DestinationDB.db3"); File.Copy(path, destinationPath); }
Friday, March 22, 2019 4:53 AM -
User369979 posted
I'm not sure whether /data/data/com.companyname.SQLite/files/Student.db3 exists. But your code above just copied the file in your app's document folder, I think you should use this path. Then copy it to your MyDocuments's folder so that you could find it there.
Friday, March 22, 2019 5:30 AM -
User366365 posted
@LandLu now i modified that code like below
var dbName = "Student.db3"; var path = Path.Combine("/data/data/com.companyname.SQLite/files/", dbName);
if (File.Exists(path)) { string destinationPath = Path.Combine("/data/", "DestinationDB.db3"); File.WriteAllText("/data/data", "DestinationDB.db3"); }
throwing the exception like System.UnauthorizedAccessException: Access to the path '/data/data' is denied and I have given permissions in android manifest
Friday, March 22, 2019 6:21 AM -
User369979 posted
After analyzing your storing path, I find it is the MyDocument folder path. This is a private directory to your application so you won't be able to see these files using a file browser unless it has root privileges. You could try this https://stackoverflow.com/questions/26396105/specialfolder-personal-location/26396658#26396658 to find your file there.
- Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
Friday, March 22, 2019 8:36 AM -
User366365 posted
Thank u @LandLu ..If I want to browse through browseDB tool how to do that?
Friday, March 22, 2019 9:23 AM