Reputation: 2658
I use an SQLiteDatabase in my application which I created manually and then using it in the android application. To navigate through it I am using a Cursor. I am showing the results from rows in edit texts.
When the orientation changes, irrespective of the row which was shown, the first row is shown in the edit Text. I know that android recreates the activity on orientation change and calls onCreate() method again.
But according to the documentation, I shouldn't store a Cursor Object in onRetainNonConfigurationInstance() since it uses a Context.
Here is the code for creating Cursor.
DataBaseHelper myDbHelper = new DataBaseHelper(this);
Cursor c=myDbHelper.getDatabase().rawQuery("SELECT * FROM mytable",null);
Another recommended way is to handle the changes manually, but I do not want to do so since I want to take advantage of the default adjustment of UI.
How can I continue with the same row when the orientation changes ?
Upvotes: 1
Views: 126
Reputation: 6668
One of the simplest way is to add this in your manifest file (for the concerned activity) -
android:configChanges="orientation|screenSize|keyboardHidden"
Upvotes: 1