How Exactly Updating Play Apps Occur - android

The Question is how exactly google play updates apps.
I mean does it remove older app exactly from files or it just append on it .
For example in my app i have a local database ,after update, will my older local database become removed?

Your old application is definitely deleted. Your app is compiled and packaged, it won't be opened by Google.
As far your database, if you made changes to your database you need to change the "database version" before publishing. And put code inside the onUpgrade() method of your SQL database. This is how you can successfully change your database. If you want to delete the old database, you can delete it inside the method. The database is on the user's device, and will stay there forever until they delete your app or your code deletes it.
I hope I'm understanding your question.

Related

Upgrade Android app and keep old SQLite database

I'm writting a small app for gym exercises. I keep my records in SQLiteDatabase and I want this app to start running as fast as I finish main part of the app. But further I want to develop this app and add some more features. There will be some records in a database yet. How can I save this records and move it to new version of the app? I'm developing with Android Studio, and each run app is installed from the scratch(before previous version is unistalled and all data is deleted?) if there were any changes, right? So, how can I keep old records and add them to new version app? I have seen some answers with onUpgrade, but it wasn't that specific that i can understand them, beacause they don't tell anything about upgrading only app, not the databse. And sorry for my English :)
Installing a new version of your app doesn't necessarily remove its data (unless you uninstall it manually before installation or just clear data manually).
Also, if you change your database structure in an update, you can override
SQLiteOpenHelper's onUpgrade method in order to handle database updates properly.

do i have every time to change the database number even if i did not make any changes to my database structure to be published to google play store

I have published my android app in google play store it works fine and perfect(my app first will go and create a sqlite DB using SQLiteOpenHelper class then the index.html page will be displayed) then i noticed that users with android version 2.3.6 have error when they install the app i solved the problem without changing or adding to the structure of the DB then after publishing the new version of my app without changing the version of the database my app will not show the index.html and i think it will keep trying creating the database and the user will just see the loading message only.
So do i have every time to change the database number even if i did not make any changes to my database structure to be published to google play store.
No, you only change the database version number to a higher version ONLY if you change the structure of the database or decide to automatically add data.
For example, you can start with version 1 with a database that contains only one table: let's call it User, and the table has a column called Username. You run the query to create the table on your onCreate method. Then you release the app.
Then you decide to add more features to the app, and implement a version of the app that did not require any database changes at all. Your db version stays 1.
Then on your next app version, you decide to add a column to the User table. So what you do, is increment the db version to 2, and then run the alter table statement on your onUpgrade method. Then you release the app.
I believe your issue lies somewhere else. Check your database data integrity and that it fits your app's model.

How to delete the data while re-install the app

Thanks for previous replies,
is it possible to delete the stored content from sqlite once re-install the application. I am storing data in database, once i re-install the same app again, the previous data still stores in sqlite. i want to delete the stored content while re install the app. i am not sure about this.
This seems like a hack and maybe not the actual answer, but can you -- with each new version of your app -- increment an identifier (from 10 to 11) in the code and then check against a stored preferences containing that identifier. If you have a constant in your code that is higher than the identifier stored on the previous device, then you can clear the database to whatever you think its state should be. Then with each new released version of the app you increment this number..
Edit: In API level 9 and higher, you can -- whenever your app starts up -- write the date in which the app was installed (see here for an explanation on how to find the install date). If you check that it was installed after the date which is written, kill the data!
Thanks for all replies,
I maintain the Version code for all the builds, once i re-install the application, i check the version, if i found the version changes, i simply remove the DB. this case only applicable for overriding the install of APk(ie without un-installing the application). When we made a uninstall, the internal data and sqlite for the application ill automatically deleted.
sqlite databases are stored as files on your file system, to delete the data. You just need to delete the file.
What you'd want to do is setup some way of detecting if the app is being run for the first time, if this is the first time the app has been run then check the database exists, if it does delete it. Then recreate the database as empty.
Or you could go through and remove all the data in each table/drop each table in the database on the first run if the database exists.
Read here : Detect Android app upgrade and set Application class boolean for show/hide of EULA
Create a UpgradeBroadcastReceiver of your own that will run the delete instructions you want and register it in your manifest file.
When you delete the app, then the database should be deleted too. Unless you go to some trouble to keep it. If you simply update the app, then the data should be kept. If you need to delete the data upon reinstall, try this:
Every time you start an Activity, call PackageManager.getPackageInfo() and check lastUpdateTime. Compare it with a time stamp that you store in the database or a shared preference. If lastUpdateTime is newer, delete the your database.
application SharedPreferance is deleted on un-installing the app, so save a boolean to determine if the application is running for the first time or not.

Strategy for updating Android app (with database)

Please forgive me if this question has been answered - I searched and couldn't find it.
I have an Android app that I want to upgrade, and it uses a SQLite Database. I want to update some of the application logic in the app, but there will be no updates to the database schema or contents. I basically need to keep the database exactly as-is for the user.
Do I need to do anything in onUpgrade to ensure that the database is kept, or can I leave the DB stuff alone for this update?
The onUpgrade() method is used incases of version change. Which means the database stored in the phone needs to be altered or dropped or deleted and a new database to be created. As your application does not have any of these requirements you can leave the DB stuff for this update.
This related article may help you with your question.
The way that I understand it, is that you need to put your database changing code in onUpdate() if you WANT to update between versions. But since you don't intend to, and are probably keeping the database version the same, then you will most likely have no issues at all.
Upgrading will NOT interfere with SQLite. Changes to db structure will not be implemented unless you programmatically do so (in onUpgrade method) or you uninstall and reinstall your app.
As long as it is the SAME application that you are upgrading, your db will not be affected and your data will not be affected either. If you change the signing key used in building your apk, your db will be recreated.
Conversely, if you change database structure at any given point, your onUpgrade method will come into play. You will be forced to backup, drop, recreate and repopulate tables which have been changed between versions (oher tables remain untouched both in structure and in data).
NOTE: In debugging, i just uninstall and reinstall the app every time i make db changes, but in production you DONT want to do that.

android sqlite on application update

I hava an android application which consists sqlite database in the assets folder.
In the DB I have several tables, which one of them is user data (which is updated over time by using the application - when the user installs the application this table is empty).
The other tables store data that I update.
The question is: when a user gets an updated version of my application (with sqlite database in the assets folder) from the market, I need to keep the data the user updated by using the application, but i do want to update the other tables (which consist my data).
What is the correct way to do it?
Thank You :)
Keep a version number for each change and implement the onUpgrade method for the possible combinations. See more in the javadoc for SQLiteOpenHelper
Since you said your tables are empty when the Database is first created, it shouldn't be necessary to add the Database from the /assets-folder.
Instead, you can use a SQLiteOpenHelper, which offers an onCreate()-method that can do the initial table-creation (an add some example data if necessary).
If you then update your app, you simply increase the Database-version and the onUpgrade()-method is called, where you can then perform the Database update.
See this other question: Run some code when user update my app
If your app comes with a huge Database and inserting entry's in the SQLiteOpenHelper isn't the right way to go, you can still check if the Database already exists and then do the updating (through the onUpgrade()-method) and keep the users data.

Categories

Resources