This question already has answers here:
How to access data/data folder in Android device?
(18 answers)
Closed 4 months ago.
I want to have an SQLite db in my flutter app, so i followed this flutter cookbook: https://flutter.dev/docs/cookbook/persistence/sqlite
I open the database with the following path: join(await getDatabasesPath(), 'doggie_database.db') exactly like the tutorial. I ran the app on my Android phone (not emulator).
Now i want to inspect the database file on my PC, but i cannot find the file on my phone.
I debugged the above statement and it resolves to /data/user/0/*mypackage*.*app-name*/databases/doggie_database.db, but i can't find the folder /data (only Android/data) or the file in my file manager neither on my phone nor on my pc.
Where is the file and how can i extract it from my phone?
I found the solution that works on Android. It is possible to extract the database file by using adb.
Connect the phone via USB
use the adb shell
type run-as *mypackage*.*app-name*
you are in the /data/data/*mypackage*.*app-name* folder
cd into the databases folder
copy the database file (i.e. cp doggie_database.db /storage/self/primary/Documents)
Use these 2 articles as reference:
https://denniskubes.com/2012/09/25/read-android-data-folder-without-rooting/
https://blog.shvetsov.com/2013/02/access-android-app-data-without-root.html
In the case of iOS simulator,
you can easily find the sqlite database storage location with the following code.
getDatabasesPath().then( (value) => print(value) );
flutter: /Users/*** your name *** /Library/Developer/CoreSimulator/Devices/4769664D-2588-4E47-A29F-5CD9DB801595/data/Containers/Data/Application/3F53C2F3-687C-4E3D-8611-66A6D8BFC84B/Documents
Related
I'm posting this to assist users who will be encountering the same thing I did when trying to locate a sqlite database being used on the iOS simulator when using Appcelerator.
xCode Version: 8.3.x
Appcelerator Studio: 4.8.x / SDK: 6.x
Issue/Test Case: I need to test several iterations of loading data from the sqlite database to a remote mySQL server. I want to place an existing sqlite database file in the folder and have the simulator recognize this file so I can use it for testing/development.
Question: Where is the sqlite database stored on the iOS simulator, can I place an existing sqlite database in this folder and have my app recognize it?
Answer: Yes
Steps to achieve:
This is what I did to locate where the simulator/device is looking for
1. Find out where your application is located in the filesystem by adding this code in your index.js (or another file of your choosing).
Ti.API.info("app directory: " + Ti.Filesystem.applicationDataDirectory);
This will give you the long filesystem directory location:
/Users/[username]/Library/Developer/CoreSimulator/Devices/96662E38-C659-4568-B53F-C32DC6B2B73D/data/Containers/Data/Application/96662E38-C659-4568-B53F-C32AB6B2C03D /Documents/
2. This was almost the correct location but the sqlite database is actually stored in the following location:
/Users/[username]/Library/Developer/CoreSimulator/Devices/96662E38-C659-4568-B53F-C32DC6B2B73D/data/Containers/Data/Application/96662E38-C659-4568-B53F-C32AB6B2C03D /Library/Private Documents/[filename].sql
3. You can use this location to put an existing sqlite database file and execute sql statements against it.
4. I'm sure you could reference another directory in your app but I was looking for the default storage directory since my app uses this location.
Hope this helps someone, as I was looking for this specific functionality for testing/development.
Happy Coding!
An easy way to get the database included is to simply add it to the resources folder, or a sub folder in the resources directory. Then you simply call the Ti.Database.install() method. This will copy the database into the simulator location you found. The upside with this method is that you don't have find the location for each iOS simulator (i.e. iPhone 5, 6, 6 plus, 7...).
I do use your method when I need to query the database externally with SQLite manager or another such program.
You can read more here http://docs.appcelerator.com/platform/latest/#!/guide/Working_with_a_SQLite_Database
I try to add core data's - with data already loaded - sqlite database to the project. I am running App on simulator, on device I get no problem. The goal to preload fresh launching app with data. In the document folder I have 3 database file:sqlite, sqlite-shm, sqlite-wal. I have chosen to copy to the project only the sqlite file. When I restarting App with preoloaded database, It seems that database is empty. Why? On device there would be only one database file, which would be not corrupted. Database connection was not closed on simulator, or what?
I found here the answer: How to preload data into an iOS app using sqlite files
In oder to get core data to behave in the old way (pre-iOS 7), and generate just the sqlite file, I had to add this argument to the addPersistentStoreWithType:configuration:URL:options:error: method call, in the options parameter. You can find it in AppDelegate.
#{ NSSQLitePragmasOption : #{ #"journal_mode" : #"DELETE" } }
I have a database from an existing android app that I need to import into my Windows Phone 8 app. Is the only way to do this to create some huge population script to be ran on the first loading of the app?
I am currently using the new sqlite-net-wp8 by Peter Huene as directed by this blog post. But the examples are all about creating the database, not using an existing one. Any help would be great.
This link shows how to copy an existing sqlite database in Windows 8. The ability to do it on a phone is the same.
1) Add the sqlite database into your project and set the type to content in its properties.
2) When your app loads, load the file into a storage file. Then write it back out using the localfolder as the destination.
WP8 only supports local (in local file) databases.
Check your solution and search for database file. If file does't exist then You can only copy by script.
I am using sqlite in my app, i want to edit some data in my database,for that i want to open it using any sqlite administration tool. but i dont know where the file is located.
i am workring in windows phone 7
If you want to get the database that is stored in your emulator then you can use the "Isolated Storage Explorer".
Just follow the instructions on the link below and it will show you how to retrieve/save the database from/to your emulator
Isolated Storage Explorer
As ry8806 said. it worked for me
i did the following ;
get my app Product id from WMAppManifest.xml file
then open "Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool" in command line and
typed : ISETool.exe ts xd (Product GUID) (desktop-path)
I get all the files stored in isolated stroge.
Hi I installed QLite Pro but Im unable to connect to a local SQLite file db how can I do this?
The fields to fill are:
Name:
Host: requeire
UserName:
PassWord:
Database:
Port:
At the end I solved this by using the program DB Browser for SQLite, I also tried the Firefox plugin but this one is better.
You can't! Sequel Pro is only for MySQL databases.
Same problem here, i couldn't make it work.
So I downloaded this firefox plugin: https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ which works fine.
Here's a small guide on how to open a sqlite database from a app in the iPhone simulator
Run your application on simulator (so that the database file will be copied to your application's documents folder (don't bother if you don't know exactly what it means))
Run the SQLite Manager plugin in Firefox (Tools -> SQLite Manager)
Open the database (You can find the file by navigating: /Libraries/ApplicationSupport/iPhone Simulator/User/Applications/(*number)/Documents
*number is some sequence of hexadecimal numbers identifying current application bundle - you must just find the proper folder (it will contain .app)
It is also possible with database on device, but first you must download application's documents folder to some place on your computer. You can download the folder by going in Xcode -> Organizer, then select your Device and Summary Tab, then under the Applications list find your application, click the triangle |> to expand it, then click the arrow on the right to download the application's documents folder.
Source: http://www.iphonedevsdk.com/forum/iphone-sdk-development/42573-browsing-sqlite3-database.html