Context is an abstract class, whose implementation is provided by Android System. It provide acces to application related resources,databses,shared preferences... We have different ways to access the context. When to use getContext()? Any instance which is not running long time, there we can use getContext(). We can use it in long running instances but we need to hanlde it by theire lifecycle methods to avoid memory leaks. When to use getBaseContext()? Inside activity life cycle we can use the getBaseContext(), this will be lives until the activity lifecycle alive. When to use getApplicationContext()? getApplicationContext() returns the application context of entire application. It will live untile the application life cycle, once application terminated it will destory When to use getThemedContext()? This context will be used to hanlde the views theme context inside the actionbar. Note: we have to use proper context on the lifecycle of each instance to avoid the memory leaks in the application.
What is "shared preferences" in Android ?
How to save activity State in Android?
Fix Play Store Rejection Due to SMS Permission - RRutors
Permission denied for window type 2010 in Marshmallow device
How to get complete address from latitude and longitude?
What is NetworkOnMainThread Exception?
Open PDF in Google Drive with Intent in Android - RRutors
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to get an image resource by it's name in android?
How to get a contact image using a phone number in android?
How To Set Text Color Programmatically Android TextView?
How to find Android Device UDID or unique ID?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
FCM Not Receiving Notifications in Android - RRutors
What is Context?
How do I check in SQLite whether a table exists?
What are Android Versions available?
What is the difference between match_parent and fill_parent?
How to Generate signed apk with android studio
How to convert milli seconds to hours, minutes and seconds in Android?
How do I generate random numbers in Dart?
How to convert DP to Pixel and Pixel to Dp?
How to get screen size (width,height) in Android?
How to Use Deprecated Handler() in Android - RRutors Guide
Decompile APK Files: How to Get Source Code - RRutors Guide
What is ANR in android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Set Activity to Fullscreen Mode in Android - RRutors
Android Studio project R can't find
Fix Duplicate Files in APK Build.gradle Issue - RRutors
What are the notifications available in android?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to check Android version?
How to validate email address in Android with Kotlin?
Key Points to remember while develop the Android Application.
Explain Fragment Life Cycle
How to reduce APK package size?
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is ANR? How to avoid and resolve it?
How do i load image from drawable folder in Jetpack Compose?