AndroidViewModel vs ViewModel

AndroidViewModel provides Application context If you need to use context inside your Viewmodel you should use AndroidViewModel (AVM), because it contains the application context. To retrieve the context call getApplication(), otherwise use the regular ViewModel (VM). AndroidViewModel has application context. We all know having static context instance is evil as it can cause memory leaks!! … Read more

How to clear navigation Stack after navigating to another fragment in Android

First, add attributes app:popUpTo=’your_nav_graph_id’ and app:popUpToInclusive=”true” to the action tag. <fragment android:id=”@+id/signInFragment” android:name=”com.glee.incog2.android.fragment.SignInFragment” android:label=”fragment_sign_in” tools:layout=”@layout/fragment_sign_in” > <action android:id=”@+id/action_signInFragment_to_usersFragment” app:destination=”@id/usersFragment” app:launchSingleTop=”true” app:popUpTo=”@+id/main_nav_graph” app:popUpToInclusive=”true” /> </fragment> Second, navigate to the destination, using above action as parameter. findNavController(fragment).navigate( SignInFragmentDirections.actionSignInFragmentToUserNameFragment()) See the docs for more information. NOTE: If you navigate using method navigate(@IdRes int resId), you won’t get the … Read more

What is AndroidX?

AndroidX – Android Extension Library From AndroidX documentation We are rolling out a new package structure to make it clearer which packages are bundled with the Android operating system, and which are packaged with your app’s APK. Going forward, the android.* package hierarchy will be reserved for Android packages that ship with the operating system. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)