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.
How to reduce APK package size?
Decompile APK Files: How to Get Source Code - RRutors Guide
Key Points to remember while develop the Android Application.
How do I generate random numbers in Dart?
How to get a contact image using a phone number in android?
How to Get bitmap from drawable: Android
What are Android Versions available?
What is Context?
Set Activity to Fullscreen Mode in Android - RRutors
Check List for Generate Signed APK Android
What happens next when the device switches between portrait and landscape?
How to get an image resource by it's name in android?
What is Intent? What is the difference between an implicit intent and an explicit intent?
FCM Not Receiving Notifications in Android - RRutors
What is ANR? How to avoid and resolve it?
Fix Android Emulator Kill Error When Running Your App
How do I check in SQLite whether a table exists?
How to save activity State in Android?
Fix Play Store Rejection Due to SMS Permission - RRutors
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is Application?
How to validate email address in Android with Kotlin?
Hide/Disable soft keyboard on Activity launch: Android
How to find Android Device UDID or unique ID?
Android Studio project R can't find
Permission denied for window type 2010 in Marshmallow device
How to convert DP to Pixel and Pixel to Dp?
Extract Date and Time from Long Type Variable - RRutors
How to Generate signed apk with android studio
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to copy database from assets folder in android using kotlin
How to get screen size (width,height) in Android?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to start a new activity on button click
What is the difference between match_parent and fill_parent?
What is NetworkOnMainThread Exception?
What is Android?
What is Android Fragments?
How to Use Deprecated Handler() in Android - RRutors Guide
Explain Fragment Life Cycle