I have this database that contains information about celebrities, lots of information, ie movies, roles, articles...
Without the viewmodel, all of the stuff in the edit text gets lost. So i dont want to lose all of that info on rotation.
So i send an intent with all the relevant info of a selected celebrity(sql room) to the addeditactivity, so now how do i initialize the viewmodel? If I do getStringExtra in onCreate, wouldn't that just rewrite the viewmodel again when the activity gets recreated?
how do i get around this, also is there a better alternative? im a beginner, thanks in advance!
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// ......... shared preferences code .................
// get intent code ................
mViewModel = ViewModelProviders.of(this).get(testViewModel.class);
mViewModel.celebName = intent.getStringExtra(CELEB_NAME);
// similar..........
}