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.
Related
I am using wildfly-10 server. I am providing an option to Upload images or jsp files for the user in the UI and the user can make use of these files in the other section of the application later.
At any one point of time I am allowing only one entry with a particular name. If the user tries to upload file with a name that is already existing then I am trying to overwrite the existing one with the new file.
In this scenario I am facing the below problem:
I have uploaded a image with the name image1.png.
Now if I change some other image's name to image1.png and upload it, the new image is not visible until I restart the server.
Looks like the older image has been cached by the server and it is still referring to the cache location. When I restart the server then it refreshes the cache with the new content of the file.
Is there any way that I can immediately see the changes in the UI whenever I re-upload the modified file?
I am using a custom folder to store the uploaded files in my server.
Is there way that I can enable deployment directory scan for this particular directory only?
You don't have to restart the server, a redeploy of the application should work.
You can define another deployment scanner or the directory scanned by the scanner: http://wildscribe.github.io/WildFly/16.0/subsystem/deployment-scanner/scanner/index.html
Another solution would be to create overlays http://wildscribe.github.io/WildFly/16.0/deployment-overlay/index.html .
Thirdly with exploded deployments WildFly already provide the functionality you have developed: https://wildfly.org/news/2017/09/08/Exploded-deployments/ (note that all jboss-cli operations can be called using HTTP rest API)
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.
I have a weird problem. I have a database in main bundle in my app. When the app launches it checks whether there is a database in documents directory. If not, then it copies there from bundle. Everything was Working before I update Xcode. Now, when I try to delete an old database from bundle and to put the new one, it still copies the old. Eventhough I've put it into trash and cleaned trash.
Can anyone suggest a solution? Because I'm a bit confused with it.
I tried some way and I found out that when I add a new file to the project - it just doesn't add there... Though in Xcode I see it in bundle....
You should remove the application from simulator or device. Your application in the simulator has already copied the database from main bundle to documents directory.
So, if you will reinstall the app, your new database will be installed.
I have a lot of jpeg+png+html files to add to my app, and of course when i "build" it all my resources files are added/included in myApp mainBundle folder.
I'd like to be able to modify via code, in run time, some of my resources, but:
1) we cannot "write" files via code in run-time in mainBundle
2) we can do it just in "documents" folder (or temp, or...)
3) we can copy files in "Documents" folder just via code in run-time
4) we cannot delete the mainBundle files after coping them in "Documents"
but that means that we will have doubled-sized our app, and in big apps (it's my case) this should be a non-sense, we'll have a lot of big files never used again in the mainBundle...
so i wondered if there was a work-around for this problem (is it just me thinking it's a non-sense?) to add files directly in the "Documents" folder in the "build" phase via xCode, or other similar solutions...
ps
one could be to download all files the first time a user use my app via server/internet directly in "Documents" folder, so my app won't be heavy to download via iTunesStore, but of course this will get a lot of time the first time for end-users, and it could be not well accepted, of course...
Well you can't, since the document directory is created on installing the app. There is no way to do what you want on compile time. Neither you can do it at the install.
Since you needed the file you have to include them in your bundle, i've even included 10MB sqlite database that I copy to to the document direct on first launch. That is just the way it is.
Doesn't work for apps
Copying files to the documents directory during compile time requires you to know that directory in advance. You generally can't know this as the documents directory might not have been created before your app is installed.
Can work for unit tests on the simulator
However, the location of the documents directory depends on the target platform and the kind of bundle you are building. For unit tests based on SenTestingKit executed on the iOS simulator, you can determine the documents directory at compile time by just doing this inside a "Run Script" build phase:
~/Library/Application Support/iPhone\ Simulator/$IPHONEOS_DEPLOYMENT_TARGET/Documents
Note that this really only works for unit test bundles as those are not executed in a dedicated app directory and thus access a "shared" documents directory on the simulator platform.
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.