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
Related
I just submitted an app to the App store and it is now available. Unfortunately I realized that my development test data was included in the SQLite database! How do I go about emptying my database for the distribution, in other words removing all rows from tables? I know how to do this for a simulation (Reset content and settings), but since the deployed version just uses the Generic iOS build that does not run in the simulator, I am not sure how to clear the database.
Figured this out myself. You have to find the location of the sql file in your project.
Find the .sql file in your project.
Go to File-> Show in Finder
Then go to that location using Terminal and use sqlite3 to set up your DB as you want it.
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!
Is there a way to preview current content of particular table in Core Data? I create an app, and I would like to know what is inside at that time. I have found a way with SQLPro app from AppStore but I have to find that .sqlite file, copy, and then open it in program. So far I haven't found a way to preview database all time while it changes.
Find the .sqlite file in your mac system application document path and open .sqlite file directly from that path using SQLITE App or Firfox sqlite ad on.
Each time you refresh the sqlite DB and you can see current content of the table.
Please note below point:
Do not copy the file to another path location and open the file.
Find .sqlite file from 'document path' in your mac system. Because it'll only contain current content of the table. Do not try to open .sqlite file from bundle path.
(for ex:Yosemite ▸ Users ▸ Rifluxyss ▸ Library ▸ Developer ▸ CoreSimulator....)
Fire Fox sqlite ad on IDE is more user friendly than sqlite app. So please try to download fire fox sqlite ad on and use it.
CoreDataPro is an OSX application developed by mFluent LLC and is meant to simplify the development and debugging of CoreData enabled applications.
With help of the this utility we can able to show the data of coredata.
With This utility to solve your problem.
Here is the link for that.
You can use Core Data Lab to view and track data changes in real time. While tracking data changes, the app also displays the previous values of any data change.
Info page: https://betamagic.nl/products/coredatalab.html
Free 14-trial: https://betamagic.nl/downloads/Core%20Data%20Lab%20Trial.zip
Diclaimer: I'm the creator of this tool.
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.
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.