title: How can I dependency injection Context into ViewModel using Hilt in Android Studio?
body: <p>Before, I use Code A to pass <code>Context</code> to <code>ViewModel</code>.</p>
  <p>Now I hope to use Hilt as dependency injection to pass <code>Context</code>,</p>
  <p>I have  read the <a href="https://stackoverflow.com/questions/63565943/application-dependency-to-viewmodel-with-hilt">article</a> , and Code B is from the article.</p>
  <p>1: Is the Code B correct way to pass <code>Context</code> into <code>ViewModel</code>?</p>
  <p>2: In my mind, in order to use Hilt in Android Studio project, I have added such as the Code C in project, do I need to use <code>fun provideApplicationContext() = MyApplication()</code> in Code B?</p>
  <p><strong>Code A</strong></p>
  <pre><code>class HomeViewModel(private val mApplication: Application, val mRepository: DBRepository) : AndroidViewModel(mApplication) {
    ...
  }
  </code></pre>
  <p><strong>Code B</strong></p>
  <pre><code>class MainViewModel @ViewModelInject constructor(
      @ApplicationContext private val context: Context,
      private val repository: Repository,
      @Assisted private val savedStateHandle: SavedStateHandle
  ) : ViewModel() {
      ...
  }
  
  
  @Singleton
  @Provides
  fun provideApplicationContext() = MyApplication()
  </code></pre>
  <p><strong>Code C</strong></p>
  <pre><code>@HiltAndroidApp
  class MyApplication : Application() {
  }
  </code></pre>