Android Architecture Components (Jetpack ਦਾ ਹਿੱਸਾ) ਲਾਇਬ੍ਰੇਰੀਆਂ ਹਨ ਜੋ ਮਜ਼ਬੂਤ, ਰੱਖ-ਰਖਾਅ ਯੋਗ ਐਪਸ ਬਣਾਉਣ ਵਿੱਚ ਮਦਦ ਕਰਦੀਆਂ ਹਨ — ਜਿਸ ਵਿੱਚ ViewModel (lifecycle-aware ਸਥਿਤੀ), LiveData/StateFlow (observable ਡੇਟਾ), ਅਤੇ Room (ਇੱਕ ਡੇਟਾਬੇਸ ਅਬਸਟ੍ਰੈਕਸ਼ਨ) ਸ਼ਾਮਲ ਹਨ। ਉਹ ਸਿਫਾਰਸ਼ ਕੀਤੇ ਆਰਕੀਟੈਕਚਰ ਪੈਟਰਨਸ ਦਾ ਸਮਰਥਨ ਕਰਦੇ ਹਨ।
ViewModel — lifecycle-aware ਸਥਿਤੀ ਹੋਲਡਰ
VIEWMODEL holds UI-related state and logic, SURVIVING configuration changes:
→ state stored in a ViewModel SURVIVES screen rotation (the activity recreates, but the
ViewModel persists) → solves the lost-state-on-rotation problem
→ separates UI logic from the Activity/Fragment (the View just observes/displays)
