everyone.
In my app, I set the integer app version code (not the version name, but the android system value android:versionCode in the Manifest) via an integer resource.
I would like to enforce that my SQLite database has the database version automatically updated whenever I update the app, which the market decides based on the integer version code. In the constructor for my database subclass, I have tried to replace the commented line with the one below it:
protected static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
super(context, DATABASE_NAME, null, context.getInteger(R.integer.version_code));
}
}
but keep getting errors, as getInteger() is not defined in this context.
Any help with this would be greatly appreciated, especially if this is considered bas practice. Thanks!
if the error that you cant reach getInteger method,try to cast the context to the activity that initiates the sqlite.
i.e.