0 votes
in Android by
What is context in Android?

1 Answer

0 votes
by

The context in Android is the context of the current state of the application or object. The context comes with services like giving access to databases and preferences, resolving resources, and more.

There are two types of context. They are:

Activity context

  • This activity context is attached to the lifecycle of an activity.
  • The activity context can be used when you are passing the context in the scope of an activity or you need the context whose lifecycle is attached to the context of the activity.

Application context:

  • This application context is attached to the lifecycle of an application.
  • The application context should be used where you need a context whose lifecycle is separate from the current context or when you are passing a context beyond the scope of activity.

Related questions

0 votes
asked Jan 1 in Android by DavidAnderson
0 votes
asked Oct 15, 2022 in Android by AdilsonLima
...