How to pack existing database in iphone DocumentDirectory instead of resourcePath - iphone

I want to pack my big database with iphone app and I don't want to copy a database from resource path to document directory for readonly problem. It's have other way to pack database to document directory or remove database from resource path after copy.
Thanks.

why not put your big database in your web server.
when your application first start, to make a initialized request to this database ,
and download it .save it in your document directory.

Related

Transferring MongoDB data

So, as the documentation says, by default, it stores data in the data/db/ directory. As I can see through the file manager, the folder is empty. I guess the documents are hidden there.
So, If I pull a repository with this folder from another PC, will I be able to access this data through MongoDB?
I guess the documents are hidden there
Unlikely. I'm betting that your data dir is set to another value.
If I pull a repository with this folder from another PC
This may work, but, at best, it'll overwrite your local data files. At worst, it'll overwrite your local data files and mongodb won't boot with your new data files.
A recommended/supported way is to use mongodump/mongorestore. Bonus point: you won't have to care about where your data files are on both computers.
If you have installed MongoDB for example from Debian/Ubuntu package the data directory will be /var/lib/mongodb.
See https://askubuntu.com/questions/982673/where-is-mongo-database-folder-on-the-filesystem

How do I specify the path to my SQLite database in Slick?

I'm trying the Play framework with Scala and Slick for data access.
I'm playing with the play-scala-intro example app. I'm trying to set up my own database instead of using the bundled in memory H2 database.
I can't figure out how to specify the path to the database file.
If the code in application.conf reads:
slick.dbs.default.db.url="jdbc:sqlite:/test.db"
slick.dbs.default.db.driver="org.sqlite.JDBC"
where should my test.db file be placed?
Does that mean the test.db file should be in the home directory of the web app, meaning the root play-scala-intro dir, or the app/assets dir?
I'd say storing your database in Java resources (and that's where assets will end up) doesn't sound like a good idea to me. I would be surprised if nothing went wrong during e.g. writing to DB.
It would be better to have it in the same directory as JAR, and even better set some defaults and let them be overridden:
database.location="test.db"
database.location=${?DBLOCATION}
slick.dbs.default.db.url="jdbc:sqlite:"${database.location}
This should assume that your database is names test.db and placed in your working directory (see: https://stackoverflow.com/a/21061029/1305121). It can be overridden using environment variable DBLOCATION like:
export DBLOCATION="/tmp/my/database.db"
# run Play application

Does iTunes backup core data?

I did some research about backup files and data in iCloud and I was wondering if the Core Data would get saved in an iTunes backup if i would not use any iCloud functionality.
So i got an application with recent server connections saved in core data to fill it back into a UITableView. If i make a device backup with iTunes and restore it later on another device would the recent connections still show up?
None of the Q/A I found did explicit answer this question.
Another question besides: Is it possible to try these itunes-backup things with an app which is in developement?
This depends on where you save your core data database.
In general the Library and the Documents directory are backed up by iTunes (and by iCloud), tmp and Caches are not backed up.
See: Apple Documentation - iOS Standard Directories: Where Files Reside
AppName.app
This is the app’s bundle. This directory contains the app and all of its resources.
You cannot write to this directory. To prevent tampering, the bundle directory is signed at installation time. Writing to this directory changes the signature and prevents your app from launching. You can, however, gain read-only access to any resources stored in the apps bundle. For more information, see the Resource Programming Guide
The contents of this directory are not backed up by iTunes. However, iTunes does perform an initial sync of any apps purchased from the App Store.
Documents/
Use this directory to store user-generated content. The contents of this directory can be made available to the user through file sharing; therefore, his directory should only contain files that you may wish to expose to the user.
The contents of this directory are backed up by iTunes.
Documents/Inbox
Use this directory to access files that your app was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your app in this directory. Document interaction controllers may also place files in it.
Your app can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes.
The contents of this directory are backed up by iTunes.
Library/
This is the top-level directory for any files that are not user data files. You typically put files in one of several standard subdirectories. iOS apps commonly use the Application Support and Caches subdirectories; however, you can create custom subdirectories.
Use the Library subdirectories for any files you don’t want exposed to the user. Your app should not use these directories for user data files.
The contents of the Library directory (with the exception of the Caches subdirectory) are backed up by iTunes.
For additional information about the Library directory and its commonly used subdirectories, see The Library Directory Stores App-Specific Files.
tmp/
Use this directory to write temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running.
The contents of this directory are not backed up by iTunes.

SQLite Database Copy

Is it is necessary to copy my local Database.sqlite to Documents directory in ios environment?
If Yes .,then please explain or refer link..
You need to copy it because if you put it on your app main bundle, it will be readOnly, and that's not what you want. So you must copy your .sqlite in Documents directory, or whatever directory where you have write permission.

Is it possible to overwrite sqlite db in IPhone app

I have created the application which is based on Sqlite database.
So in my app, initially i have created the Sqlite db with one data and i have added that db into my "Resource" folder in my project.
While app running at first time, checking db in Documents folder(Sandbox) if no file means, copy the db from Resource to Document folder.
After that every insert and delete operations performing on Db in Document folder only. not on db in Resource folder.
So, i have inserted 50 items in db and then i have deleted the app from Simulator(or) device.
When deleting app, db also deleted with that.
My question is ==> How to overwrite the Sqlite db(in Resource folder) with db(in Documents folder) when every updation in app(insert, delete)?
because db file in Documment folder getting update while inserting items into that.
I am using XCode 4.2 with iOS 5 sdk.
You cannot change the Resource bundle once you created (i.e app file). You cannot overwrite the SQLite db into resource folder of your bundle.
If you still want to keep previous db then just copy it from simulator path and replace whenever you clean and build the app.
EDIT:
You can go to /Users//Library/Application Support/iPhone Simulator/"Simulator version you use"/Application/"check all folder to find your app inside this folder"/ "YOUR APP.app"
Then Right Click APP file and Click Show Package Content. Now you will be able to see the resources you used in App file. You can search your DB and BACKUP/REPLACE it.
First off the database file in the app bundle (resource folder) is read only and can't be changed by the app.
Second when an update is installed, all the files in the app bundle get replaced by the files in the update. The files in the document directory aren't touched.
if you need to update the database file in the document directory you will need to implement an update method some where and keep track of the versie of the database used.
There is no way you can modify any resource present inside the application bundle.That's why we copy the database file to the documents directory of the application, so we can modify the file. If you want to preserve data, you backup the data using the iCloud service.
You have to do this by opening another handle for the database in your resource folder and perform the operation for that too. I assume you need it only when you run it in simulator for convenience.
You cannot do this when you run in device.
Its true that there is no way to copy that document folder data again to resource bundle, so i will suggest u to take a backup of that db before deleting the application from simulator or from the device.