---
title: "Query"
description: "Query"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/android/reference/query"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-06"
---

# Query

## Query

The Get all entries request fetches the list of all the entries of a particular content type. It returns the content of each entry in JSON format. You need to specify the environment and locale of which you want to get the entries. We can apply filters on query also.

## removeHeader

The removeHeader method removes a header from the request using the specified header key.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.removeHeader(key)
```

key of the header you want to remove

## getContentType

The getContentType method retrieves the content type associated with the request.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.getContentType()
```

## where

The where method filters entries by applying a condition that matches a specified field key with the provided value.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.where("uid", "entry_uid");
```

key of query parameter

value of query param

## addQuery

The addQuery method adds a custom key-value pair to the query URL, enabling support for extended or non-standard query parameters.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.addQuery("key", "value");
```

key of query parameter

value of query param

## removeQuery

Remove provided query key from custom query if exist.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.removeQuery(key);
```

Query name to remove.

## and

The and method combines multiple queries using the AND operator to retrieve results that meet all specified conditions.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
query.and(array);
```

List of Query instances on which AND query executes.

## or

The or method retrieves all entries that meet any of the specified queries by combining them using the OR operator.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
query.or(array);
```

the value that provides an upper bound

## lessThan

The lessThan method applies a constraint that requires a specified key to have a value lower than the given value to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");
```

The key to be constrained

the value that provides an upper bound

## lessThanOrEqualTo

The lessThanOrEqualTo method applies a constraint that requires a specified key to have a value less than or equal to the given value to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
```

The key to be constrained

The value that must be equalled.

## greaterThan

The greaterThan method applies a constraint that requires a specified key to have a value greater than the given value to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.greaterThan("due_date", "2013-06-25T00:00:00+05:30");
```

The key to be constrained

The value that provides an lower bound.

## greaterThanOrEqualTo

The greaterThanOrEqualTo method applies a constraint that requires a specified key to have a value greater than or equal to the given value to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.greaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
```

The key to be constrained

The list of values the key object should not be.

## notEqualTo

The notEqualTo method applies a constraint that requires a specified key to have a value not equal to the given value to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notEqualTo("due_date", "2013-06-25T00:00:00+05:30");
```

The key to be constrained

The list of values the key object should not be.

## containedIn

The containedIn method retrieves entries by applying a constraint that requires a specified key to have a value contained within the provided array.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.containedIn("severity", new Object[] { "Show Stopper", "Critical" });
```

The key to be constrained

The list of values the key object should not be.

## notContainedIn

The notContainedIn method retrieves entries by applying a constraint that requires a specified key to have a value not contained within the provided array.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notContainedIn("severity", new Object[] { "Show Stopper", "Critical" });
```

The key to be constrained

The list of values the key object should not be.

## exists

The exists method applies a constraint that requires a specified key to be present in the response to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.exists("status");
```

The key to be constrained

## notExists

The notExists method applies a constraint that requires a specified key to be absent from the response to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notExists("status");
```

The key to be constrained

## includeReference

The includeReference method adds a constraint that includes the details of a specified reference key in the response to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeReference(key);
```

key that to be constraineda

## tags

The tags method includes the specified tags as a search criterion in the query to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.tags(new String[] { "tag1", "tag2" });
```

Comma separated array of tags with which to search entries.

## ascending

The ascending method sorts the results in ascending order based on the specified key to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.ascending(key);
```

The key to order by.

## descending

The descending method sorts the results in descending order based on the specified key to retrieve entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.descending(key);
```

The key to order by.

## only

The only method retrieves entries by specifying an array of keys in the base object that should be included in the response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
<span>query.only(new String[]{"name"});</span>
```

Pass the field UID.

## onlyWithReferenceUid

The onlyWithReferenceUid method retrieves entries by specifying an array of only keys that should be included in the response for referenced entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
query.onlyWithReferenceUid(array, "for_bug");
```

Array of the only reference keys to be included in response

Key who has reference to some other class object

## exceptWithReferenceUid

The exceptWithReferenceUid method retrieves entries by specifying an array of except keys that should be excluded from the response for referenced entries.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
query.exceptWithReferenceUid(array, "for_bug");
```

## count

The count method retrieves the total count along with the data objects that match the query criteria.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.count();
```

## includeCount

The includeCount method retrieves the count of objects along with the data in the response that match the specified query conditions.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeCount();
```

## includeContentType

The includeContentType method retrieves objects along with the content type details of all returned objects in the response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeContentType();
```

## includeOwner

The includeOwner method retrieves objects by including the owner’s profile information in each object’s data.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.<span>includeOwner</span>()
```

## skip

The skip method retrieves objects by skipping a specified number of objects before returning the results.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.skip(3);
```

Number of objects to skip from returned objects

## limit

The limit method retrieves entries by setting a limit on the number of objects to return.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.limit(3)
```

Number of objects to limit.

## regex

The regex method retrieves entries by applying a regular expression constraint that matches string values against the provided pattern, which may result in slower performance for large data sets.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.regex("name", "^browser", "i");
```

The key to be constrained.

The regular expression pattern to match

Any of the following supported Regular expression modifiers.

\- use i for case-insensitive matching.

\- use m for making dot match newlines.

\- use x for ignoring whitespace in regex

## locale

The locale method retrieves entries by setting the language based on a specified locale code.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.locale("locale-code");
```

language code

## search

The search method retrieves only the entries that match the specified search value.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.search("header");
```

value used to match or compare

## findOne

The findOne method retrieves entries that match the query conditions and optionally caches the result to improve performance.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.findOne(new QueryResultsCallBack() {
Override public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
```

The key as string which needs to be added to the Query

## addParam

The addParam method adds a key–value parameter to an entry request.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.addParam(key, value);
```

The key as string which needs to be added to the Query

The value as string which needs to be added to the Query

## includeReferenceContentTypUid

The includeReferenceContentTypeUid method retrieves entries by including the content type UIDs of referenced entries in the response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.includeReferenceContentTypUid()
```

## whereIn

The whereIn method retrieves entries by applying conditions to referenced fields and returns those that match the specified values.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.whereIn("due_date", query);
```

The key to be constrained

queryObject is Query object, so you can chain this call

## whereNotIn

The whereNotIn method retrieves entries by applying conditions to referenced fields and returns those that do not match the specified values, functioning as the opposite of the $in query.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context,apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.whereNotIn("due_date", query);
```

The key to be constrained

Query object, so you can chain this call

## includeFallback

The includeFallback method retrieves entries by including fallback language content in the response when content for the specified locale is unavailable.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeFallback();
```

## includeEmbeddedItems

The includeEmbeddedItems method retrieves entries by including embedded items in the query response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeEmbeddedItems();
```

## includeBranch

The includeBranch method retrieves entries by including branch information in the response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context,apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
<span>entry.includeBranch();
```

## includeMetadata

The includeMetadata method retrieves entries by including query metadata in the response body.

```
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", environment_name);
Query query = stack.contentType("contenTypeUid").query();
query.includeMetadata();
```

## Query | Android Delivery SDK | Contentstack

Query fetches all entries of a content type in the Android Delivery SDK, returning JSON content with support for filters, environment, and locale.