How to store/retrieve application data incase application deleted accidentally - iphone

I am having an application in which I am having SQlite database too ..If I delete that Application accidentally. Is there any way to get back the same application with the same database.
Or Is there any way to keep database alone in a separate place inside iPhone memory so that we can recover after application delete if needed.
Please tell me how to achieve the above?.
Regards,
V.K.

Every iPhone app runs in a "Sandbox", which is where it stores its application files and databases. When you delete the app, the whole sandbox is deleted, including your SQLlite database. There is no way to write it outside of the sandbox short of having another app that listens on a URL and having the app in question write to that URL.

Related

How to run code during app uninstall in flutter

I would like to run code to delete files created on local storage when my flutter app is uninstalled. How can I do the same? Is there any event to handle this? If not, how can I clean up the images generated?I don't see any reference online for this.
If you are saving images to users gallery, that image is no longer the domain of your app, in any way shape or form. If you create a gallery within your app this would be different, also, a gallery within your app would in fact be deleted along with any other memory your app uses. I highly doubt you could access users gallery & delete images even with users permission.
Possible backend server solution: here
This indicates this is not possible as per below:
All of your app's files are deleted by the OS when the user deletes
the app. If Apple wanted developers to have that capability, we would
have that capability 🙂
You could make a case for needing to know the app is deleted if you
are storing stuff on the server side. Currently from the server's
point of view there's no way to know whether the app was deleted or
the user just stopped using it. But locally stored files are not an
issue.
I am also looking for a solution to this & I think server logic will get it done.
Must be some sort of logic possible to discover server side if user is GONE!

Best practice for sending data updates to iPhone app?

I'm currently in the middle of developing an iPhone app with a big reference database (using Core Data backed with a pre-populated sqlite database). Once the app is live and deployed to a client's iPhone, I need the facility to update/insert a small amount of data. What are best practices / methods for doing this?
There may be occassions when the frequency of updates will be daily for a month or so. Other occassions when a data update happens once every few months.
What is the recommended way of doing this? Note, I don't anticipate any data model changes for these updates -- this is purely an insert/update of data.
At the moment I'm starting to research the use of push data notifications (q:payload size restrictions?), app store updates (q:code/data model only, not data updates?) and the use of my own ad hoc data server (which the app connects to routinely to check for updates).
Can anyone please provide me any pointers on the above?
Thanks in advance
IIRC Push Notifications have a maximum payload of 256 bytes. Enough for notification purposes, but not more. Your app would still have to download the actual data from your own server after receiving the notification.
Note that the app bundle is not writable on the device. So if your app needs to update the data store, you should copy the pre-populated database file from the app bundle to the app's documents directory on first launch.
App Store updates would certainly be feasible (especially now that Apple seems to have gotten its review process down to a few days at most) but note that an App Store update will always replace the entire app bundle (code and data), so if your pre-populated reference database is big, the customer would have to download it in full every time.

How to get any update from Mysql to SQLite in iphone

I have to download only updated data from my mysql database that I have created at server.
i also have SQLite database for iphone .
Now i want any changes in database would prompt the user for doing updating.
Also an update button will be there for updating.
how to identify the data is updated in the database.
Also is there any code for synchronizing will be good for understanding
You might want to take a look at objective sync = it provides synchronisation and integration between a local sqlite db on ithe iPhone and a RESTful web application (the interface to your Mysql DB on the server).
How else does the app communicate with the server? Why not have the app ping the server to find out if the MySQL DB is updated? Can the app check email outside of the iPhone's email client? You could generate a userID for each app User, and whenever changes are made to the MySQL server, it sends an email to the app telling it updates are available. There may even be a way to do this via something like XMPP/Jabber.
Essentially, the app has to talk to the server to get the updates regardless of how it finds out if there are updates. So that means it talks to the server in general. If that's the case, just have the server send the app an alert that there are messages. If you want the server to "push" this alert to the phone, you'll have to figure out what push methods you have available in iPhone apps.
But once you know how the server will alert the user/app/phone, you can eliminate the user's need to hit an update button, and just have the app replace the sqlite file with the updated sqlite file from the server. Since the sqlite file just reflects what is in the MySQL DB, you can avoid the headache of updating the app's file by just replacing it with an updated version.

When to persist data in iPhone application?

I'm currently creating an iPhone app where in one part of my app you can view your twitter stream. I'm unsure if I need to ever save the twitter information to a sqlite database or not.
So here is the flow of this part of the app:
press button to see twitter stream
go get twitter stream
display twitter stream in table view
I'm wondering if I should ever save the twitter stream into a database. Any advice?
I would say you should save the twitter stream. You should almost always try to save some application state in an iPhone app. This way, if the user is interrupted (a phone call) they can jump back into your app without missing a beat.
There are a few different ways to persist data in an iPhone app. Instead of bothering with using a SQLite database you will almost certainly want to use Core Data, which is new in iPhone OS 3.0
If you won't ask the user to provide his/her twitter credentials and it will be an anonymous stream, you don't need to store anything.
But the minute you want to store some preferences, actual state (to show the user what he/she was seeing when a phone call came or after application restart) you will need to store persistent data.
I think it's important to cache web data. With a cache, you can present data immediately on app startup - this is important on the iPhone OS because users are constantly opening and closing apps. Having your data immediately available is a big win for the user.
You can make the caching very simple, just have a single table with the URL as one column and the HTTP response as a second. Then you don't have to change any of your code to make the caching happen.
Alternatively, you will need to define a data model and manage that through CoreData or sqlite.

Writing to SQLite3 on iPhone simulation

I have an app that is running in the simulator. I read and write from a sqlite3 data source. However, if i restart the app, then all datg that i had previously wrote to the db is lost.
The data is always in its original state.
Now back when i was developing this app i thought i read somewhere that data can not be persisted via iphone simulator.
Can anybody confirm or deny this?
Thanks!
You need to place your db file in a writable place, e.g. in the Documents folder. All the bundle files are read-only files.
If you are distributing an initial database with the app, you will need to copy it to Documents (or another folder) and use the copy.
You also need to ensure that you close the database connection in your application is closing (i.e. you receive a applicationWillTerminate message).