Android

Android MVVM Architecture

MVVM Architecture with Jetpack: ViewModel, LiveData, Data Binding, Separation of Concerns, Unidirectional Data Flow

18 Interview-Fragen·
Mid-Level
1

What is a ViewModel in Android?

Antwort

A ViewModel is a Jetpack component that stores and manages UI-related data in a lifecycle-aware way. It survives configuration changes (screen rotation) and allows separating business logic from UI.

2

How do you create a ViewModel instance in an Activity?

Antwort

Use ViewModelProvider to create or retrieve a ViewModel instance. ViewModelProvider(this).get(MyViewModel.class) ensures you get the same instance even after screen rotation.

3

Why should you never pass an Activity or View Context into a ViewModel?

Antwort

The ViewModel survives configuration changes and lives longer than Activities. Keeping an Activity Context reference would cause a memory leak. Use AndroidViewModel with Application Context if needed.

4

What is LiveData?

5

What is the difference between LiveData and MutableLiveData?

+15 Interview-Fragen

Meistere Android für dein nächstes Interview

Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.

Kostenlos starten