I have always created the view model in the onCreate method of a fragment. I have also seen some other developers creating the view model in the onCreateView method. However today i used the Android Studio template for 'Fragment with ViewModel' and the view model was created in the onActivityCreated method. Which approach is correct? If the Android Studio template is doing this in the onActivityCreated then surely there must be a reason behind this. Can any one shed light on the correct approach here?