---
title: "Contentstack Delivery Android SDK"
description: "Documentation for Android Delivery SDK"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/android/reference"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2025-09-15"
---

# Contentstack Delivery Android SDK

## Contentstack - Android Delivery SDK

## Android Delivery SDK for Contentstack

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application front end, and Contentstack will take care of the rest. [Read More](/docs/developers/sdks/content-delivery-sdk/java/about-java-delivery-sdk).

Contentstack provides Android Delivery SDK to build applications on top of Android. Given below is the detailed guide and helpful resources to get started with our Android Delivery SDK.

## Prerequisite

To get started with Android SDK, you will the following:

*   Android Studio IDE
*   Android API SDK support 19 and above
*   Java SDK version 1.8 or later

## SDK Installation and Setup

Using Android Studio, you can easily add dependencies by opening the app's **build.gradle** file, under the dependencies section in the project:

```
dependencies{    implementation 'com.contentstack.sdk:android:{version}'}
```

You can download the latest dependency version [here](https://mvnrepository.com/artifact/com.contentstack.sdk/android)

## Quickstart in 5 mins

## Initializing your SDK

**For setting the Region refer to the code below:**

```
import com.contentstack.sdk.*;
Config config = Config();
config.region = ContentstackRegion.EU;
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment", config);
```

**For setting the Branch refer to the code below:**

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

Config config = Config();
config.setBranch("branch");
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment", config);
```

**Note:** Use the following region codes based on your platform and location:

*   **NA** for North America
*   **EU** for Europe
*   **AU** for Australia
*   **AZURE NA** for Azure North America
*   **AZURE EU** for Azure Europe
*   **GCP NA** for GCP North America
*   **GCP EU** for GCP Europe

## Basic Queries

Contentstack SDKs let you interact with the [Content Delivery APIs](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) and retrieve content from Contentstack. They are read-only in nature. The SDKs fetch and deliver content from the nearest server via Fastly, our powerful and robust CDN.

**Get a Single Entry**

To retrieve a single entry from a [content type](/docs/headless-cms/about-content-types), use the code snippet given below:

```
import com.contentstack.sdk.*;Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");ContentType contentType = stack.contentType("contentTypeUid");Entry entry = contentType.entry("entryUid");entry.fetch(new EntryResultCallBack(){	@Override public void onCompletion(ResponseType responseType, Error error) {   if (error == null) {    System.out.println("response: "+entry.title); }}});
```

  

**Get Multiple Entries**

To retrieve multiple entries of a particular content type, use the code snippet given below:

```
import com.contentstack.sdk.*;Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");Query query = stack.contentType("contentTypeUid").query();query.find(new QueryResultsCallBack(){@Override public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error){         if(error == null) {      System.out.println("response: "+entry.title);  }}});
```

**Note:**

*   Currently, the Android SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer to the [Queries](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#queries) section of our Content Delivery API documentation
*   By default, the limit for response details per request is 100, with the maximum limit set at 250.

## Pagination

In a single instance, the [Get Multiple Entries](/docs/developers/sdks/content-delivery-sdk/java/get-started-with-java-delivery-sdk) query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the **skip** and **limit** parameters in subsequent requests.

```
import com.contentstack.sdk.*; Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment"); Query query = stack.contentType("contentTypeUid").query();  query.skip(20).limit(20).find(new QueryResultsCallBack(){    @Override  public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error){    if(error == null){     System.out.println("response: "+queryResult);   }}  });
```

## Contentstack

Contentstack class that exposes Stack instance

## stack

The stack method provides access to the stack of your site, allowing users to retrieve and manage content within a single space.

```
import com.contentstack.sdk.*;
 
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
Example with Config:

import com.contentstack.sdk.*; 

Config config = new Config().setHost("api.contentstack.io");
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
```

The application context

API Key of your application on Contentstack

Delivery Tokens retrieves only the published entries of the environment with which it is associated

A publishing environment refers to one or more deployment servers or a content delivery destination (Webpage’s address) where you will publish your content ([entries](/docs/headless-cms/about-entries) or [assets](/docs/headless-cms/about-assets)).

Config instance to set environment and other configuration details.

## Contentstack

## Contentstack | Android Delivery SDK | Contentstack

Contentstack exposes the Stack instance in the Android Delivery SDK, serving as the entry point for accessing your content.

## Config

Config class that exposes config instance, Where the user can provide other configurations on the stack

## setBranch

The setBranch method sets the target branch for the stack to retrieve content from a specific development or release branch.

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

Config config = new Config();
config.setBranch("branchName");
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment", config);
```

branch you want to set

## getBranch

The getBranch method retrieves the branch currently set on the stack.

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

Config config = new Config();
config.getBranch();
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment", config);
```

## setProxy

The setProxy method sets a custom proxy to route SDK network requests through a specified HTTP proxy server.

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

java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80));
Config config = new Config();
config.setProxy(proxy);
```

Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object

## getProxy

The getProxy method retrieves the current proxy instance configured for routing network requests.

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

Config config = new Config();
config.getProxy();
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

## getRegion

The getRegion method retrieves the region associated with the request URL.

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

Config config = new Config();
config.getRegion();
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

## setRegion()

The setRegion method sets the database region for your stack. You can choose from seven regions: NA, AU, EU, Azure NA, Azure EU, GCP NA, and GCP EU.

```
import com.contentstack.sdk.*;
Config config = new Config();
config.setRegion(ContentstackRegion.EU);
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);
```

You can choose from seven regions namely, NA, EU, AU, Azure NA, Azure EU, GCP NA, and GCP EU.

## getHost()

The getHost method retrieves the host associated with the request URL.

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

Config config = new Config();
config.getHost();
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

## setHost()

The setHost method sets a custom host for the request URL to direct API calls to a specified endpoint.

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

Config config = new Config();
config.sethost(hostname);
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

The host

## getVersion()

The getVersion method retrieves the version of the request path.

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

Config config = new Config();
config.getVersion();
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

## enableLivePreview()

Enables Live Preview

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

Config config = new Config()
config.enableLivePreview(true)
Stack stack = Contentstack.stack(context,"apiKey", "deliveryToken", "environment", config);
```

Provide true to enable the Live Preview

## setLivePreviewHost()

Sets Host to the Live Preview request url

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

Config config = new Config()
config.setLivePreviewHost(host)
Stack stack = Contentstack.stack(context,"apiKey", "deliveryToken", "environment", config);
```

Host for Live Preview

## setManagementToken()

The setManagementToken method adds the management token to the stack header to authorize content management operations.

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

Config config = new Config();
config.setManagementToken(managementToken);
Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
```

The Management Token

## earlyAccess

The earlyAccess method retrieves features by enabling the early access header, allowing access to functionalities that are part of the early access program.

```
Example:

Config config = new Config();
String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"};
config.earlyAccess(earlyAccess);
stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);
```

## Config | Android Delivery SDK | Contentstack

Config exposes a configuration instance in the Android Delivery SDK, letting you set additional options on the Contentstack stack.

## Asset

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

## fetch

The fetch method retrieves a particular asset using its asset UID.

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

Stack stack = Contentstack.stack(applicationContext, "apiKey", "deliveryToken", "environment");
Asset asset = stack.asset("assetUid");
asset.fetch(new FetchResultCallback() {
@Override 
public void onCompletion(ResponseType responseType, Error error){

}}
```

callback of the asset response

## includeBranch

The includeBranch method includes the branch information in the asset response.

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

Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
Asset asset = stack.asset("assetUid");
asset.includeBranch();
```

## includeFallback

The includeFallback method includes the fallback language content in the asset response when the specified locale content is unavailable.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.includeFallback();
```

## includeMetadata

The includeMetadata method includes the asset metadata along with the response body.

```
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
final Asset asset = stack.asset("assetUid");
asset.includeMetadata();
```

## addParam

The addParam method adds a query parameter to the asset request to filter the response.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.addParam();
```

Key of the header you want to add

Add value to the header against the header key

## includeDimension

The includeDimension method includes the dimension information such as height and width in the asset response.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.includeDimension();
```

## setTags

The setTags method includes the specified tags in the asset response to categorize the asset.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.setTags()
```

## getTags

The getTags method retrieves the array of tags associated with the asset in the response.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.getTags()
```

## getDeletedBy

The getDeletedBy method retrieves the deleted by object from the asset response, indicating which user deleted the asset.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.getDeletedBy()
```

## getDeleteAt

The getDeleteAt method retrieves the deleted at object from the asset response, indicating the timestamp when the asset was deleted.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken","environment");
Asset asset = stack.asset("assetUid");
asset.getDeleteAt()
```

## getUpdatedBy

The getUpdatedBy method retrieves the updated by object from the asset response, indicating which user last updated the asset.

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

Stack stack = Contentstack.stack(context,"apiKey","deliveryToken", "environment");
Asset asset = stack.asset("assetUid");
asset.getUpdatedBy();
```

## getUpdateAt

The getUpdateAt method retrieves the updated at object from the asset response, indicating the timestamp when the asset was last updated.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getUpdateAt();
}
});
```

## getCreatedBy

The getCreatedBy method retrieves the created by object from the asset response, indicating which user created the asset.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreatedBy();
}
});
```

## getCreateAt

The getCreateAt method retrieves the created at object from the asset response, indicating the timestamp when the asset was created.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreateAt();
}
});
```

## toJSON

The toJSON method retrieves the JSON object representation of the asset from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.toJSON();
}
});
```

## getUrl

The getUrl method retrieves the URL of the asset from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.<span>getUrl()</span>;
}
});
```

## getFileName

The getFileName method retrieves the file name of the asset from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.<span>getFileName()</span>;
}
});
```

## getFileSize

The getFileSize method retrieves the file size of the asset from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileSize();
}
});
```

## getFileType

The getFileType method retrieves the file type of the asset from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileType();
}
});
```

## getAssetUid

The getAssetUid method retrieves the asset UID from the asset response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getAssetUid();
}
});
```

## removeHeader

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

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.removeHeader(headerKey);
```

Key of the header you want to remove

## setLocale

The setLocale sets the locale for a single asset request. Call it before Asset.fetch() so the SDK includes the locale in the GET request.

**Note:** The response contains the asset data for the specified locale. Field-level values depend on your stack’s localization settings and how the [Content Delivery API](/docs/developers/apis/content-delivery-api) serves localized assets.

```
Additional Resource: Refer to the List of Supported Languages document to follow the standard code format or refer to Add a Custom Language document to create and add a custom language.
Example: Creates a stack, fetches an asset with a locale, and reads its fields via getters or toJSON().
import android.content.Context;
import com.contentstack.sdk.*;
import org.json.JSONObject;

Context context = getApplicationContext(); // e.g. call from Activity; or pass Context in from your layer

try {
    Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
    Asset asset = stack.asset("<ASSET_UID>");
    asset.setLocale("en-us").fetch(new FetchResultCallback() {
        @Override
        public void onCompletion(ResponseType responseType, Error error) {
            if (error == null) {
                String fileName = asset.getFileName(); // use in UI or downloads
                JSONObject json = asset.toJSON();
                if (json != null) {
                    String title = json.optString("title"); // empty string if key missing; API may localize per locale
                }
            } else {
                String message = error.getErrorMessage(); // e.g. log or show to the user
            }
        }
    });
} catch (Exception e) {
    // Handle stack initialization failure (e.g. log or surface to the user)
}
```

Locale code for the asset (e.g., "en-us"). Sent as the locale query parameter.

## Asset | Android Delivery SDK | Contentstack

Asset represents a single media file from your Contentstack repository in the Android Delivery SDK, giving access to its details and methods.

## AssetLibrary

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

## sort

The sort method sorts the asset library based on order criteria.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.sort(keyOrderBy, ORDERBY.ASCENDING);
```

the key order by

the orderby can be applied using ORDERBY enums

## includeCount

The includeCount method includes the total count of assets in the asset library response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeCount();
```

## includeRelativeUrl

The includeRelativeUrl method includes the relative URLs of assets in the asset library response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeRelativeUrl();
```

## includeMetadata

The includeMetadata method includes the asset library metadata along with the response body.

```
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", environment_name);
AssetLibrary assets = stack.assetLibrary();
assets.includeMetadata();
```

## setHeader

The setHeader method adds a header to the request using the specified key and value.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.setHeader(key, value);
```

The key you want to remove from the header

Value of the header against the key

## removeHeader

The removeHeader method removes a header associated with the specified key.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.removeHeader(key);
```

The key you want to remove from the header

## includeFallback

The includeFallback method includes the fallback language content in the asset response when the specified locale content is unavailable.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeFallback()
```

## getCount

The getCount method returns the total number of assets available in the stack.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.getCount()
```

## fetchAll

The `fetchAll` method retrieves all the assets available in the stack without applying any filters.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.fetchAll(new FetchAssetsCallback({

});
```

The callback of type FetchAssetsCallback

## where

The where method retrieves assets from the stack by applying filter conditions on any field UID associated with the assets.

```
Example:
   import com.contentstack.sdk.*;
   Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
   AssetLibrary assets = stack.assetLibrary().where("field_name","value");
   assets.fetchAll(new FetchAssetsCallback(){
    @Override
    public void onCompletion(ResponseType responseType,List<Asset> assets,Error 
    error)
{ 
  System.out.println(assets);
 }});
```

Enter the field UID of the asset

Enter the value

## AssetLibrary | Android Delivery SDK | Contentstack

AssetLibrary retrieves the media files uploaded to your Contentstack repository through the Android Delivery SDK, fetching collections of assets.

## ContentType

Content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.

## removeHeader

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

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.removeHeader(headerKey)
```

The key of the header

## entry

The entry method retrieves a specific entry, which is an actual piece of content created using one of the defined content types.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.entry("entryUid")
```

TThe unique ID of the entry that you want to fetch

## query

The query method returns a query instance for building and executing advanced entry queries on a specified content type.

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

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

## fetch

The fetch method retrieves all the content types available for the stack.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.fetch(new JSONObject(), new ContentTypesCallback() {
 @Override
public void onCompletion(ContentTypesModel model, Error error) {
   JSONArray resp = model.getResultArray();
}
});
```

key value parameters of type JSONObject

The callback of type ContentTypesCallback

## ContentType | Android Delivery SDK | Contentstack

ContentType defines the schema of a page or section in the Android Delivery SDK and is used to create and fetch entries built from it.

## Entry

An entry is the actual piece of content created using one of the defined content types.

## exceptWithReferenceUid()

The exceptWithReferenceUid method specifies an array of except keys that gets excluded from the response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.<span>exceptWithReferenceUid</span>()
ArrayList<String> array = new ArrayList<String>();
<span>array.add("description");</span>
<span>array.add("name");</span>
<span>entry.onlyWithReferenceUid(array, "referenceUid");</span>
```

Array of the except reference keys to be excluded in response

Key who has reference to some other class object

## onlyWithReferenceUid

The onlyWithReferenceUid method specifies an array of reference UIDs that should be included in the response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
entry.onlyWithReferenceUid(array, "referenceUid");
```

Array of the only reference keys to be included in response.

Key who has reference to some other class object

## only

The only method specifies an array of keys in the base object to include in the response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.only(new String[]{"name", "description"});
```

Array of the only reference keys to be included in response

## includeReference

The includeReference method adds a constraint that requires the details of a specified reference key.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReference(new String[]{"referenceUid_A", "referenceUid_B"});
```

referenceFields array key that to be constrained

## except

The except method specifies an array of field UIDs that are excluded from the response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.except(new String[]{"name", "description"});
```

field uid which get excluded from the response.

## setLocale

The setLocale method sets the language of the entry.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.setLocale();
```

language code

## getLocale

The `getLocale` method retrieves the locale of the entry, indicating the language of the content.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getLocale();
```

## getUid

The getUid method retrieves the UID of the entry.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getUid()
```

## getContentType

The getContentType method retrieves the content type of the entry.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getContentType()
```

## getTags

The getTags method retrieves the tags associated with the entry.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.<span>getTags</span>()
```

## removeHeader

The removeHeader method removes a header associated with the specified key.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.removeHeader(key);
```

key of the header you want to remove

## setHeader

The setHeader method adds a header using the specified key and value.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.setHeader(key, value)
```

key of the header you want to remove

value of the header against the key

## fetch

The fetch method retrieves the entry using its UID, and can optionally include query parameters to refine the response.

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

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.fetch(new EntryResultCallBack() {
@Override public void onCompletion(ResponseType responseType, Error error) {
}
});}
```

EntryResultCallBack object to notify the application when the request has completed

## addParam

The addParam method adds query parameters to the entry request to filter the response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.addParam(key, value)
```

key of the header

value of the header

## includeReferenceContentTypeUID

The includeReferenceContentTypeUID method includes the content type UIDs of referenced entries in the entry response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReferenceContentTypeUID()
```

## includeContentType

The includeContentType method includes the content type UID of the entry.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeContentType()
```

## includeFallback

The includeFallback method includes the fallback language content in the entry response when the specified locale content is unavailable.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeFallback()
```

## includeEmbeddedItems

The includeEmbeddedItems method includes embedded items in the entry response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeEmbeddedItems()
```

## includeBranch

The includeBranch method includes the branch information in the entry response.

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

Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("user").entry("entryUid");
entry.includeBranch();
```

## includeMetadata

The includeMetadata method includes the entry metadata along with the response body.

```
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", environment_name);
Entry entry = stack.contentType("contentTypeUid").entry("entryUid");
entry.includeMetadata();
```

## variants

The variants method retrieves details of a specific entry variant or an array of entry variants based on the applied query.

When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uid header.

```
Example 1:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack
                    .contentType("contentType")
                    .entry("entryUid")
                    .variants("variantUid/variantAlias");
 entry.fetch(new EntryResultCallBack() {
     @Override
     public void onCompletion(ResponseType responseType, Error error) {
              System.out.println(entry.toJSON());
         }
 });
Example 2:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack
                    .contentType("contentType")
                    .entry("entryUid")
                    .variants(new String[]{"variantUid1/variantAlias1","variantUid2/variantAlias2"});
 entry.fetch(new EntryResultCallBack() {
     @Override
     public void onCompletion(ResponseType responseType, Error error) {
              System.out.println(entry.toJSON());
         }
 });
```

Enter the UID/Alias of the variant

## Entry | Android Delivery SDK | Contentstack

Entry represents a single piece of content created from a content type in the Android Delivery SDK, giving access to its field data.

## 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.

## Global Fields

A Global field is a reusable field (or group of fields) that you can define once and reuse in any content type within your stack. This eliminates the need (and thereby time and efforts) to create the same set of fields repeatedly in multiple content types.

**Example:**

```
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
GlobalField globalField = stack.globalField();
globalField.findAll(new GlobalFieldsResultCallback() {
@Override
public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
if(error == null){
JSONArray result = globalFieldsModel.getResultArray();
} else {
System.out.println("❌ Error: " + error.getErrorMessage());
       }
    }
});
```

## fetch

The fetch method retrieves the details of the specified global field.

```
Example:

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
GlobalField globalField = stack.globalField("globalFieldUid");
globalField.fetch(new GlobalFieldsResultCallback() {
@Override
public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
if (error == null) {
JSONArray result = globalFieldsModel.getResultArray();
System.out.println("Global Fields Response: " + result);
} else {
System.out.println("Error: " + error.getErrorMessage());
       }
    }
});
```

UID of the global field

## findAll

The findAll method retrieves the details of all the global fields of the stack.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
GlobalField globalField = stack.globalField();
globalField.findAll(new GlobalFieldsResultCallback() {
@Override
public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
if(error == null){
JSONArray result = globalFieldsModel.getResultArray();
} else {
System.out.println("Error: " + error.getErrorMessage());
       }
    }
});
```

## includeBranch

The includeBranch method includes the branch details in the result for single or multiple global fields.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
GlobalField globalField = stack.globalField("globalFieldUid").includeBranch();
globalField.fetch(new GlobalFieldsResultCallback() {
@Override
public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
if (error == null) {
JSONArray result = globalFieldsModel.getResultArray();
System.out.println("Global Fields Response: " + result);
} else {
System.out.println("Error: " + error.getErrorMessage());
       }
    }
});

Note:Information about Global fields can be retrieved by all users, regardless of their role or access level.
If your Global field contains nested Global fields, they will appear as part of the schema in the API response.
```

## Global Fields | Android Delivery SDK | Contentstack

Global Fields are reusable fields you define once and reuse across content types in the Android Delivery SDK, saving repeated field setup.

## Taxonomy

[Taxonomy](/docs/headless-cms/about-taxonomy) helps you categorize pieces of content within your stack to facilitate easy navigation and retrieval of information.

**Example:**

```
import com.contentstack.sdk.*;Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);Taxonomy taxonomy = stack.taxonomy();
```

## in

The in method retrieves all entries for a specific taxonomy that satisfy the given conditions provided in the $in query.

```
Example:
Taxonomy taxonomy = stack.taxonomy();
List<string> listOfItems = new ArrayList<>();
listOfItems.add("maroon");
listOfItems.add("red");
taxonomy.in(taxonomy,listOfItems).find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter the list of taxonomy fields

## or

The or method retrieves all entries for a specific taxonomy that satisfy at lease one of the given conditions provided in the $or query.

```
Example:
Taxonomy taxonomy = stack.taxonomy();
List<jsonobject> listOfItems = new ArrayList<>();
JSONObject item1 = new JSONObject();
item1.put("taxonomies.color", "orange");
JSONObject item2 = new JSONObject();
item2.put("taxonomies.country", "zambia");
listOfItems.add(item1);
listOfItems.add(item2);
taxonomy.or(listOfItems).find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the list of taxonomy fields

## and

The and method retrieves all entries for a specific taxonomy that satisfy all the given conditions provided in the $and query.

```
Example:
Taxonomy taxonomy = stack.taxonomy();
List<JSONObject> listOfItems = new ArrayList<>();
JSONObject items1 = new JSONObject();
items1.put("taxonomies.color", "green");
JSONObject items2 = new JSONObject();
items2.put("taxonomies.country", "india");
listOfItems.add(items1);
listOfItems.add(items2);
taxonomy.and(listOfItems).find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the list of taxonomy fields

## exists

The exists method retrieves all entries for a specific taxonomy if the value of the field, mentioned in the condition, exists.

```
Example:
Taxonomy taxonomy = stack.taxonomy().exists(taxonomy, Value);
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter true/false

## equalAndBelow

The equalAndBelow method retrieves all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term.

```
Example:
Taxonomy taxonomy = stack.taxonomy().equalAndBelow(taxonomy, termsUid);
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter the UID of the term

## below

The below method retrieves all entries for a specific taxonomy that match all of their descendant terms by specifying only the target term and a specific level.

**Note:** If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example:
Taxonomy taxonomy = stack.taxonomy().below(taxonomy, termsUid);
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter the UID of the term

## equalAbove

The equalAbove method retrieves all entries for a specific taxonomy that match a specific term and all its ancestor terms, requiring only the target term and a specified level.

**Note:** If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example:
Taxonomy taxonomy = stack.taxonomy().equalAbove(taxonomy, termsUid);
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter the UID of the term

## above

The above method retrieves all entries for a specific taxonomy that match only the parent term(s) of a specified target term, excluding the target term itself and a specified level.

**Note:** If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example:
Taxonomy taxonomy = stack.taxonomy().above(taxonomy, termsUid);
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("RESULT:",response.toString());
   }
});
```

Enter the UID of the taxonomy

Enter the UID of the term

## find

The find method is used to get API response.

```
Example:
taxonomy.find(new TaxonomyCallback() {
   @Override
   public void onResponse(JSONObject response, Error error) {
       Log.d("Result:",response.toString());
   }
});
```

The callback class that contains the API response

## Taxonomy | Android Delivery SDK | Contentstack

Taxonomy lets you categorize stack content in the Android Delivery SDK, enabling easy navigation and retrieval through hierarchical classification.