Core Data not saving directly to sqlite - ios

In the old days, when I developed iOS app using Core Data for < iOS 7, I remembered that if I am not mistaken, sqlite file in emulator was not saved directly. I need to go to Home in iPad, then the sqlite file was updated.
Now I faced same thing. I observe my sqlite file never get modified, only the SHM and WAL file. So how can I check my data in sqlite?
The data is being persisted by Core Data since my app can fetch the new inserted/updated data.
Any advices from anyone?

Finally after some research, because I copy and paste the 3 sqlite files from emulator to desktop, it seems the files lost all link and the data isn't displayed. Open the sqlite file directly inside emulator, works!

Related

How can I know what is in the core data

I'm currently working on a IOS project and using Core Data. My question is:
Is there any tool or software I can use to see what data is in the Core Data when I'm running the project, and how to use them. Thank you so much!
Once your app has run in the simulator it creates a persistent store file, you can find the file in your app's document's directory:
~/Library/Application Support/iPhone Simulator/User/Applications
You can also check out CoreDataEditor or CoreDataPro.
There are some tools can make you efficient.
Parrot can help you enter the app sandbox easily,and you can download the app on the Mac Store.
You can use DB Browser exhibit your data .

Data is not getting from sqlite DB in device but it is working in iOS Simulator

In my app I want to display data from sqlite database on UIPicker View.It is working fine in ios simulator but data is not fetched when using iphone device.I m not getting the issue.How it can be solved???
Are you sure there is sqlite file available at path? sqlite3_open() will create the file if its not exists. Please check wheather you have created sqlite file in bundle, if yes you cannot do that. The file actually has to already exist and be copied into the bundle as a resource at build time, then used as a template to copy to a writeable area like the documents folder. The best way, if you intend to create a writeable database, would be to get the path to the Documents directory and use that. You can and should do that unconditionally, without regard to whether you are running on the Simulator or not. Indeed, I would suggest not creating any more differences between Simulator behavior and device behavior than you face anyway.

How to preload data into an iOS app using sqlite files

Prior to the new Xcode 5 build, I was able to preload data into my core data powered app by referencing the file from the project. However, ever since I upgraded my XCode, my json data is now being saved into 3 files:
an empty .sqlite file
a .sqlite-wal file
a .sqlite-shm file.
How do I do import this data into my app?
In the past all I had to do was copy the sqlite file and I was done. Now, I have no idea what file I'm supposed to copy.
I can confirm "compacting" the database using the FIREFOX add-on provided by #Lukasz Kowalski herein is confirmed with 10.9.1 / Xcode 5 / iOS 7. To clarify procedure...
download Firefox, then get his SQLite Manager add-on.
Copy enclosing StoreContent folder with PersistentStore, PersistentStore-wal and PersistentStore-shm files to desktop for re-combination into single pre-iOS7 UIManagedDocument database that functions as before. where to find:
~/Library/ApplicationSupport/iPhoneSimulator/7.xx/Applications/gobble-d-gook/APPNAME/Documents/APPNAMEDatabase/StoreContent/{your database files}
Launch Firefox, open window, from menu Tools > Sqlite Manager
Use SQLite Manager to open database: desktop > StoreContent > PersistentStore
Select from Menu > Compact Database option.
Select from Menu > Close Database
done! they are combined.
I found out from apple's developer site that 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 to the persistentStore addStore method, under the options parameter.
#{ NSSQLitePragmasOption : #{ #"journal_mode" : #"DELETE" } }
I hope this helps anyone else who encounters this problem.
Cheers
Try just the sqlite file. See if it works, add the other two one by one.
You could also save the JSON in a txt file and on load parse it into Core Data. Depending on how much data you have, you should do this in batches with the first batch being just large enough to populate the first view and then continue parsing the rest. All in a background queue off course.
Not as easy as it was before, but this is a solution. Maybe someone else has a better solution?
I have found solution to create 1 .sqlite file when you have 3 files: .sqlite, .sqlite-wal and .sqlite-shm. To do that you should use „SQLite Manager” addon for Firefox (https://addons.mozilla.org/pl/firefox/addon/sqlite-manager/?src=userprofile):
install and run addon in Firefox
open your coredata .sqlite from directory of your app in iPhone Simulator
use Compact Database which will produce 1 .sqlite file :)
now you can use old method (prior to XCode 5) to include .sqlite into your application

viewing coredata with sqlite browser in xcode 5

Since upgrading to XCode 5, I am unable to view data in the sqlite file in my Applications Folder. The folder structure has changed somewhat but I can still find the correct App but when I open the sqlite file with the sqlite browser there does not appear to be any data in CoreData.
Any ideas?
I suggest you to use CoreDataPro app for viewing your CoreData storage.
My fork has minor improvement - alphabetical ordering of Simulator managed object models.
In iOS 7 SQLite's Write-Ahead Logging is turned on by default. In this mode data is split into three files (.sqlite, .sqlite-shm, .sqlite-wal). I've seen that some SQLite viewers ignore .sqlite-shm and .sqlite-wal files, thus not showing proper data.
I'm using SQLite Manager plugin in Firefox, it works pretty decent.
You can get the plugin here https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
After you install the plugin you will see 'SQLite Manager' (with a database icon in blue color) item in Tools menu.

Where is the database file stored in Blackberry OS 7 Simulators?

I am using phonegap to develop an Application on BB OS 7 simulator.
I am using sqlite and i am mounting a folder as sdcard. But i am not able to find the database which got created in the application. Although it is storing it some where but i dont know where.
Where does it get stored?
your data base saves in SDCard folder itself.if you want to check your data stored or not fallow this path "SDCard\databases\" in this you can find file ,right click on the file and select openwith select with sqlite ,the database table will opens you can ckeck inserted fields.

Resources