Android SQLite database and app update

I have developed an android app and released version 1.0. The app contains SQLite local database with 5 tables.

Now we planned to release version 2.0 also update the version 1.0 users. In version 2.0 we have included extra two tables with previous 5 table, so 7 tables now.

  • Why path drawn on scaled GLES20RecordingCanvas and simple Canvas has different qualities?
  • Is this custom CursorAdapter for a ListView properly coded for Android?
  • Difference between CursorLoader and AsyncTaskLoader
  • Disable Appcompact_v7 inclusion: Android
  • Android open browser from service avoiding multiple tabs
  • How to extract or unpack an .ab file (Android Backup file)
  • Now my question is, The version 1.0 users all have some data in the local database, If he update to the version 2.0 the previous data will get lost? If it so. then what is the alternate method?

    Related posts:

    Share image and text through Whatsapp or Facebook
    What is a “Web Application”?
    Media player 1004 error on galaxy s3
    Fused Location Provider setsmallestDisplacement doesn't work in Android
    View SQL generated by ORMLite on Android
    How to fix the error “Unable to open debugger port ” in Android Studio?
  • Arduino + Bluetooth module + Android
  • MediaStyle notification is not responding to RemoteControl events.
  • Android SearchView does not work
  • How to Support GESTURE, left/right slip, many transition effect in Android application
  • How to force a video to play in fullscreen in youtube player?
  • onStart of new Activity is called before onStop of parent
  • 3 Solutions collect form web for “Android SQLite database and app update”

    You should put all changes in your onUpgrade method you can use this code:

        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql = "ALTER TABLE " + TABLE_SECRET + " ADD COLUMN " +
         "name_of_column_to_be_added" + " INTEGER";

    this adds a column in your current database. Your database will not lose data. Reminder: onUpgrade will be called when getWriteableDatabase or getReadableDatabase is executed AND the version of your database is different from your older version.

    You can do some on SQLiteOpenHelper#onUpgrade, get some old data. and insert into new table

    Change your db version and add extra two table creation methods in your onUpgrade(SQLiteDatabase db, int oldVersion, int newVesion) method. Now the the previous data will not get lost.

    I hope this will help you.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.