Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to test upgrading sqlite database before uploading new version of my app on play store in android
    primarykey
    data
    text
    <p>I am getting issue no such table found "table_name" on my uploaded application after updating app version. I came out after testing I am getting this issue only after I upgrade the old version of app to new version of app</p> <p><strong>What I have Implemented</strong></p> <p>I have done code in the onUpgrade() method and also upgrade db version in constructor but I could not test it in the device.</p> <p><strong>step 1)</strong> Increase version code 1 to 2</p> <pre><code>public databasehelper(Context context) { super(context, DATABASE_NAME, null, 2); this.myContext = context; try { createDataBase(); openDataBase(); } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p><strong>Step 2)</strong> added new table into <strong>onUpgrade()</strong> method</p> <pre><code>@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.e("onUpgrade db", "&gt;&gt;&gt;&gt;called"); switch (oldVersion) { case 1: db.execSQL(DATABASE_CREATE_notification_counter); Log.e("db version", "&gt;&gt;&gt;"+oldVersion); // we want both updates, so no break statement here... case 2: Log.e("db version", "&gt;&gt;&gt;"+oldVersion); // I removed onCreate() method from here because new version will already have the new table // onCreate(db); } } </code></pre> <p><strong>Step 3)</strong> onCreate() method for the new version of database.</p> <pre><code>@Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE_notification_counter); Log.d("oncreate db", "&gt;&gt;&gt;&gt;called"); } </code></pre> <p>I have got the solution to upgrade database <a href="https://stackoverflow.com/questions/8133597/android-upgrading-db-version-and-adding-new-table">link1</a> <a href="https://stackoverflow.com/questions/13159210/onupgrade-sqlite-database-in-android">link2</a> <a href="https://stackoverflow.com/questions/14419358/confusion-how-does-sqliteopenhelper-onupgrade-behave-and-together-with-impor">link3</a> <a href="https://stackoverflow.com/questions/3505900/sqliteopenhelper-onupgrade-confusion-android">link4</a></p> <p><strong>Why I could not test it</strong></p> <p>we have uploaded paid app on the play store so I have to test db upgrade method in emulator or device using two different apk means older version and newer version.. and I have tested in device first time using old version and then new version(db changes with added new table in db) but onUpgrade() method will not be called at this time.</p> <p><strong>Question:</strong></p> <blockquote> <p>1) How can I test db upgrade before updating new version on the play store? </p> <p>2) It will call only when you update the version from play store only?</p> </blockquote> <p>Please help me to solve this problem.</p> <p>Answers will be appreciated. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload