How can i check update database in core data - iphone

Hi I am new in iphone app, i am just trying out some apps.
I am trying to add more data in my database, i just want to see where it is stored and my database updated or not.

The default for the template projects is that it will save a file named "NameOfProject.sqlite" into the apps document folder.
On the simulator, the app's directories will be in:
(user's home directory)/Library/Application Support/iPhone Simulator/(build iOS version number)/(UUID string)/
The text in the "()" varies.
For example, one of my projects has a path:
(my home directory)/Library/Application Support/iPhone Simulator/3.2/Applications/2E211069-AEF3-4F1F-9CA2-A18EF310F798
The name of the app's directory is a UUID and often changes so you have to constantly check.

Related

How does "Open With" some app in iPhone work?

As far as I know, from iOS SDK 3.2, file type handling is added and an iOS application can associate itself with some file type so that other applications can open this kind of file with the application.
Because of the sandbox mechanism in iOS, I wonder when a file in appA is opened with appB, which registered itself with this kind of file, what will happen? Is this file copied to appB and both appA and appB keep a copy of this file? If the answer is yes, is it possible to make appB open the file under appA's document folder? I cannot find any Apple documentation on this.
For example, appA stores a Keynote document in it, if I open this Keynote document with the Keynote app, is it possible to let Keynote app to edit this document in place so that after editing, appA can see the updated document?
Any help is appreciated.
There are a few different questions in here.
When you register your app to handle types of files using the info.plist entry Document types your app will be on the list of apps that are shown when you perform an action with that file (for example tapping a file attachment in an email). Then when your app is launched, the method application:didFinishLaunchingWithOptions: is run as normal, and the launchOptions dictionary will contain the path to the file that was sent to your app. What you do with the file from there is up to you, but it is a copy of the file, not a link to it. So if the user makes changes to the file in the original app they must 'launch' your app again, with the new file.
See here for more info: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions:
You can't access any other app's document folder with the current SDK.
Also, for sharing documents in iTunes (like Pages, Numbers etc), look into the two info.plist entries Document types and UIFileSharingEnabled. (Apples docs: http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20) Basically, by setting UIFileSharingEnabled to YES you will expose the /Documents directory of your app in iTunes. Then again it's up to your to show the user once they are back in your app what's in that directory.
Sndbox implemented over standard unix permissions control. All applications are stored in folders with unique name (actually, GUIDs), however owner for them is the same mobile:mobile.
So it looks like they just sends full file path to application which opens the corresponding file.

How to retrive Core Data SQL store from Developer's App on the Developer's iPhone

I need a copy of the store that is saved as Core Data sqlite file inside a test app installed on my device.
I know how to get files out of the the simulator at path: ~/Library/Application Support/iPhone Simulator/[Version]/Applications/[AppID]/Documents
...but i need get the .sqlite file from the app on the device itself.
Unless the app itself has file sharing built in, you can't access the documents folder from outside the app. It is a security precaution and part of the sandbox.
Update:
I misunderstood the context of the question. To get files off a developers iPhone, connect the device and open Xcode>Window>Organizer. Select the device in the lefthand pane. In the righthand pane will be a list of applications. Your custom apps will have an arrow next to it. Hit the arrow and you will see "Application Data" hit the down arrow icon and it will let you download the data to folder. That folder will contain the apps Document, Library and tmp folders.
I wrote an application specifically for this to distribute to my customers and testers of my applications when they have problems. iPhoneRescue is free and allows you to get at all of the backup information in your iPhone; this includes any sqlite files.
All the users have to do is find their device backup, find the application, and then save the application files or just a specific file. (This does not work if they have encrypted their backups).

Sqlite database is not updating

Hi am new in this field.i am trying out one app.
i am storing data in sqlite database. i am only using sqlite for my app when i add data into table from my app, I can see changes in my simulator but when i check my database there is no change and when i reset my simulator all my added data is gone. Please help me. i don't know what is wrong. there is no error.
When you say "reset my simulator" does that mean quit the app and restart it, or use the "Reset Content and Settings" option from the iPhone Simulator menu?
Doing the latter will erase all simulator apps' data, but doing the former should not.
How and where are you creating the database file that you intend to write to?
The correct thing to do is generally the following:
Put an empty copy of the database (probably with necessary tables created and any initial data already entered) in your app's bundle.
On app launch, check for the existence of the database file in your app's Documents directory. If it doesn't exist, copy it from the bundle to Documents. If it does exist, do nothing.
Your app should write to the copy of the database in your app's Documents directory. This means that the database in your app's bundle will (and must) stay the same, but the one in Documents will contain any new data.

Where is the sqlite3 database stored on the iphone emulator?

Now that I have a read-only application working, I am working on the insert statement. The insert returned OK in my code, but the read-back (in the code) came up empty, so I want to use the command line or browser to read. Can I copy the DB off the emulator and into my laptop for access with other utilities?
You can access the documents directory of your app at ~/Library/Application Support/iPhone Simulator/<SDK VERSION>/Applications/<SOME RANDOM HASH>/Documents
Note that the SDK version will be different depending on what you are building under, and the hash is tough to figure out which one is yours. Just inspect the folders and look for a YOURAPP.app binary to figure it out.
What database?
Assuming you have created it in your app's documents folder, app sandboxes for the simulator are in ~/Library/Application Support/iPhone Simulator/<version>/<uuid>, and contain the application and it's Documents, Library and tmp directories.

location of database created by the application

I have opened a database using sqlite3 in my application. When i run the application in the simulator, this database might be created and i'm playing with it. But now i need to know the location (to be accessed from ma mac) where this database is created. Surely it is not in the application folder as i'm not seeing it. I doubt it to be somewhere in the location where the simulator is installed. Anyone knowing the location. pls help me finding it.
If you're looking for the actual file on your Mac, try looking in this folder:
/Users/YOURUSERNAME/Library/Application Support/iPhone Simulator/User/Applications/
There should be a bunch of folders with long names. If you've recently built your app for the Simulator, order the folder by Date and the newest will be at the top. The folder contains a Documents folder, but you can also right-click on the app to "Show Package Contents", which might contain your database.sqlite file.