Monotouch and sqlite database - iphone

Here's the scenario: I have created a db3 file, attached it to to the solution, changed it to content (tried resource as well), and copying all the time. When I launch the app, I copy this to the document folder of the app. Now, it works flawlessly in the simulator, i.e. I can both read and write. But on the device, it's only in Read-Only mode. How do I make it writable on the device? I am using the latest ios 5 and latest monotouch.
Thanks in advance for any help.
And Merry Christmas everyone :)

Files stored in the .app directory are read-only on device.
If you need to have a read-write version of any of your data files, you need to copy this to your Documents storage area.

Related

Useful USB file transfer on iOS - How to hide some files?

I am building the iPhone application, which will support the USB file transfer function.
I modified the .plist file. And now I can see the files in Documents directory of my own iPhone application, through iTunes on Mac.
Everything is okay. However, there are some important files, which shouldn't show to the users, such as the configuration file, the database file and so on.
So here is my question - is it possible to hide some files?
Just easily, I can keep the important files out of the Documents directory. But when I update the application from appstore, these will be deleted.
Thank you.
I tried to prefix the files with a dot. And it works great.
Thank you, DanZimm.

Iphone SQLite problems

I'm developing an iphone application that read data through the sqlite.
I created a database through Terminal and added to the Xcode project.
I went back to the terminal and includes a new table in the file. sql. The problem is because my new queries do not see the new tables. This is kind a cache? How do i solve this problem?
Where is the SQLite file? Is it in your application bundle? Make sure you modify the version that's been copied to your iPhone Simulator folder (~/Library/Application Support/iPhone Simulator/) if you’re trying to modify the version running in the simulator.
What code do you use to create the database? Are you checking to see if it exists before copying it to your documents folder? If so, it exists and won't be copied.
You might try uninstalling your app from the simulator (or device) and reinstalling the app presumably with the new SQLite database. There's a few ways to get the old database in this situation.

How to transfer Core Data store from provisioned iPhone to iPhone simulator?

I have a lot of data stored in my app on my provisioned device, and I want to do additional testing on my computer which is much faster than using the device. What is the best way to transfer the data store into the iPhone simulator so I can access it on the computer?
I think that you can download the data from your device in the Organizer in Xcode.
Once you unzip that folder you should be able to find your sqlite database file.
Now look for the folder on your hard drive where the simulator keeps its files. I think it's somewhere in ~/Library/Application Support/iPhone Simulator or something like that. There should be a folder for each app somewhere in there (the folder name will be some random ID), and you should be able to find an sqlite database with the same name. Replace that database with the one you downloaded from the device.
Sorry I can't give more detailed instructions. I'm at work currently and don't have access to my Macbook to get the exact folder names and such.

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.