---
title: "Define different kind of context in android"  
description: "Define different kind of context in android"  
author: "Anonymous User"  
published: 2015-06-11  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/2619/define-different-kind-of-context-in-android  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# Define different kind of context in android

Context defines the current state of application or object. Context provides access to things such as creating new activity instance, access databases, start a service, etc. You can get the context by invoking **getApplicationContext(), getContext(), getBaseContext()** or **this** when in the activity class.\

```
//Creating ui instanceImageButton button = new ImageButton(getContext());//creating adapterListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), ...);//querying content providergetApplicationContext().getContentResolver().query(uri, ...);//start activity. Here this means activity contextIntent intent = new Intent(this, SecondActivity.class);
```

## Answers

### Answer by Anonymous User

Context defines the current state of application or object. Context provides access to things such as creating new activity instance, access databases, start a service, etc. You can get the context by invoking **getApplicationContext(), getContext(), getBaseContext()** or **this** when in the activity class.\

```
//Creating ui instanceImageButton button = new ImageButton(getContext());//creating adapterListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), ...);//querying content providergetApplicationContext().getContentResolver().query(uri, ...);//start activity. Here this means activity contextIntent intent = new Intent(this, SecondActivity.class);
```


---

Original Source: https://www.mindstick.com/interview/2619/define-different-kind-of-context-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
