• Platforms
  • Partners
  • Forums
  • 日本語
  • TLC Tealium Learning Center Tealium Learning
    Community
  • Discussions & Ideas Dicussions & Ideas
  • Product Guides Product Guides
  • Knowledge Base Knowledge Base
  • Developer Docs Developer Docs
  • Education Education
  • TLC Blog TLC Blog
  • Support Desk Support Desk
  • CDH Customer Data Hub Customer Data Hub
  • Mobile
  • Getting Started
    • Overview
    • Quick Start Guide
    • Mobile Concepts
    • Client-Side
    • Server-Side
    • Tracking Webviews
    • Data Layer
    • Consent Management
    • Event Batching
    • User Location and Geofencing
    • Media Tracking
    • Deep Links
    • Timed Events
    • Trace
    • Hosted Data Layer
    • Adobe Visitor Service Module
    • Feature Comparison
    • Troubleshooting
  • Remote Commands
    • Overview
    • How It Works
    • Integrations
      • Adjust
      • AppsFlyer
      • Branch
      • Braze
      • Contentsquare
      • Facebook
      • Firebase
      • Kochava
      • Usabilla
  • Android (Java)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Module
      • Optimizely X Tracking Module
    • Android TV
    • Android Wear
    • API Reference
      • ConsentManager
      • DataSources
      • Lifecycle
      • Tealium
      • Tealium.Config
      • TealiumLocation
    • Release Notes
  • Android (Kotlin)
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • Identity Resolution
    • Module List
      • Ad Identifier Module
      • AutoTracking Module
      • AdobeVisitorService Module
      • Collect Module
      • Collectors Module
      • Crash Reporter Module
      • In-App Purchase Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Manager Module
      • Media Module
      • RemoteCommands Module
      • Tag Management Dispatcher Module
      • Visitor Service Module
    • Android TV
    • API Reference
      • ConsentCategory
      • ConsentManager
      • CurrentVisit
      • DataLayer
      • Lifecycle
      • LocationManager
      • Media
      • Tealium
      • TealiumConfig
      • VisitorProfile
      • VisitorService
    • Release Notes
  • Cordova 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
    • API Reference
    • Release Notes
  • Cordova 2.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Flutter 1.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
    • Release Notes
  • Flutter 2.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
      • Tealium
      • TealiumConfig
      • VisitorProfile
    • Release Notes
  • iOS (Objective-C)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Tag Management
    • Module List
      • Lifecycle Tracking Module
    • tvOS
    • watchOS
    • API Reference
    • Release Notes
  • iOS (Swift) 1.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • App Extensions
    • Identity Resolution
    • Consent Management
    • Modules
    • Module List
      • AppData Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DataSource Module
      • DefaultStorage Module
      • Delegate Module
      • DeviceData Module
      • DispatchQueue Module
      • FileStorage Module
      • Lifecycle Module
      • Location Module
      • Logger Module
      • PersistentData Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
      • VolatileData Module
    • Feature Comparison
    • Working with Objective-C
    • API Reference
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManagerDelegate
      • TealiumConsentManager
      • TealiumInstanceManager
      • TealiumPersistentData
      • TealiumVolatileData
      • Tealium
    • Release Notes
  • iOS (Swift) 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • App Extensions
    • Identity Resolution
    • Modules
    • Module List
      • AppData Module
      • AdobeVisitorService Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DeviceData Module
      • In-App Purchase Module
      • Lifecycle Module
      • Location Module
      • Media Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
    • Working with Objective-C
    • API Reference
      • LocationModule
      • MediaSession
      • Tealium
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManager
      • TealiumDataLayer
      • TealiumInstanceManager
    • Release Notes
  • NativeScript
    • Overview
    • Install
    • Track
    • API Reference
      • Tealium
      • TealiumConfig
    • Release Notes
  • React Native 1.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • React Native 2.x
    • Overview
    • Install
    • Track
    • Location Module
    • API Reference
    • Release Notes
  • Unity 1.x
    • Overview
    • Install
    • Track
    • API Reference
  • Unity 2.x
    • Overview
    • Install
    • Track
    • API Reference
  • Xamarin 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Consent Management
    • API Reference
    • Release Notes
  • Xamarin 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • API Reference
    • Release Notes
  • Web
  • Getting Started
    • Overview
    • Quick Start Guide
    • Web Concepts
    • Data Layer
      • An Introduction to the Data Layer
      • How the Data Layer Works for Websites
      • Data Layer Best Practices
      • Definitions
        • Retail
        • Publisher
        • Hotel
        • Travel
        • Basic Video Tracking
  • Adobe Launch
    • Overview
    • Install
    • Data Layer
  • AMP
    • Overview
    • Install
    • Track
    • Data Layer
  • Angular
    • Overview
    • Install
    • Track
    • API Reference
  • Google Tag Manager
    • Overview
    • Install
    • Data Layer
  • JavaScript (Web)
    • Overview
    • Install
    • Track
    • Data Layer
    • Universal Data Object (utag_data)
    • Universal Tag (utag.js)
    • Data Layer Object (b)
    • Single-Page Applications
    • Settings
    • Debugging
    • API Reference
      • Cookie Functions
      • GDPR Functions
      • Tracking Functions
      • Utility Functions
    • Release Notes
  • Server
  • C#
    • Overview
    • Install
    • Track
    • Data Layer
    • API Reference
    • Release Notes
  • HTTP API
    • Overview
    • Endpoint
    • Data Layer
  • Java
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Node
    • Overview
    • Install
    • Track
    • API Reference
  • Python
    • Overview
    • Install
    • Track
    • API Reference
  • Roku
    • Overview
    • Install
    • Track
    • API Reference
  • Ruby
    • Overview
    • Install
    • Track
    • API Reference
ANDROID KOTLIN

DataLayer

Reference guide for DataLayer class and methods provided by Tealium for Android (Kotlin).

Class: DataLayer

This class provides persistent and volatile data storage for key-value data to be included with every tracked event.

The following methods are available for the DataLayer class.

Method Description
all() Retrieves all key-value pairs currently in the data layer
clear() Removes all data from the data layer
contains() Returns true if the key exists in the data layer
count() Returns a count of all values currently in the data layer
get() Retrieves the value for the given key
getBoolean() Retrieves the Boolean for the given key
getBooleanArray() Retrieves the Array<Boolean> for the given key
getDouble() Retrieves the Double for the given key
getDoubleArray() Retrieves the Array<Double> for the given key
getInt() Retrieves the Int for the given key
getIntArray() Retrieves the Array<Int> for the given key
getJsonArray() Retrieves the org.json.JSONArray for the given key
getJsonObject() Retrieves the org.json.JSONObject for the given key
getLong() Retrieves the Long for the given key
getLongArray() Retrieves the Array<Long> for the given key
getString() Retrieves the String for the given key
getStringArray() Retrieves the Array<String> for the given key
keys() Returns a List<String> of all keys currently in the data layer
putBoolean() Stores a Boolean for the given key
putBooleanArray() Stores a Array<Boolean> for the given key
putDouble() Stores a Double for the given key
putDoubleArray() Stores a Array<Double> for the given key
putInt() Stores an Int for the given key
putIntArray() Stores an Array<Int> for the given key
putJsonArray() Stores a org.json.JSONArray for the given key
putJsonObject() Stores a org.json.JSONObject for the given key
putLong() Stores a Long for the given key
putLongArray() Stores a Array<Long> for the given key
putString() Stores a String for the given key
putStringArray() Stores a Array<String> for the given key
remove() Removes the value for the given key

all

Returns a map of all the key-value pairs currently stored in the data layer.

val dataLayer = tealium.dataLayer.all()

clear

Clears all items currently stored in the data layer.

tealium.dataLayer.clear()

contains

Returns true if the given key exists in the data layer, otherwise false.

Parameters Type Description
key String The name of the variable to be removed
tealium.dataLayer.contains("KEY")

count

Returns a the number of items currently stored in the data layer.

tealium.dataLayer.count()

get

Retrieves the value at the given key. Return types match one of the allowed types, else null is returned.

The method gets a variable of type Any (equivalent to Java’s Object). Inspect the type by using type casting or instanceof in order to use the data type appropriately.

Parameters Type Description
key String The name of the variable to be retrieved
val any = tealium.dataLayer.get("KEY")

getBoolean

Retrieves the Boolean value at the given key. If the value at this key is not a Boolean, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val bool = tealium.dataLayer.getBoolean("KEY")

getBooleanArray

Retrieves the Array<Boolean> value at the given key. If the value at this key is not a Array<Boolean>, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val booleanArray = tealium.dataLayer.getBooleanArray("KEY")

getDouble

Retrieves the Double value at the given key. If the value at this key is not a Double, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val double = tealium.dataLayer.getDouble("KEY")

getDoubleArray

Retrieves the Array<Double> value at the given key. If the value at this key is not a Array<Double>, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val doubleArray = tealium.dataLayer.getDoubleArray("KEY")

getInt

Retrieves the Int value at the given key. If the value at this key is not a Int, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val int = tealium.dataLayer.getInt("KEY")

getIntArray

Retrieves the Array<Int> value at the given key. If the value at this key is not a Array<Int>, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val intArray = tealium.dataLayer.getIntArray("KEY")

getJsonArray

Retrieves the org.json.JSONArray value at the given key. If the value at this key is not a JSONArray, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val jsonArray = tealium.dataLayer.getJsonArray("KEY")

getJsonObject

Retrieves the org.json.JSONObject value at the given key. If the value at this key is not a JSONObject, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val jsonObject = tealium.dataLayer.getJsonObject("KEY")

getLong

Retrieves the Long value at the given key. If the value at this key is not a Long, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val long = tealium.dataLayer.getLong("KEY")

getLongArray

Retrieves the Array<Long> value at the given key. If the value at this key is not a Array<Long>, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val longArray = tealium.dataLayer.getLongArray("KEY")

getString

Retrieves the String value at the given key. If the value at this key is not a String, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val string = tealium.dataLayer.getString("KEY")

getStringArray

Retrieves the Array<String> value at the given key. If the value at this key is not a Array<String>, then null is returned.

Parameters Type Description
key String The name of the variable to be retrieved
val stringArray = tealium.dataLayer.getStringArray("KEY")

keys

Returns the List<String> of all keys currently stored in the data layer

tealium.dataLayer.keys()

putBoolean

Stores a Boolean value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Boolean The Boolean value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putBoolean("KEY", true, Expiry.FOREVER)

putBooleanArray

Stores a Array<Boolean> value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Array<Boolean> The Array<Boolean> value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putBooleanArray("KEY", arrayOf(true, false, true), Expiry.FOREVER)

putDouble

Stores a Double value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Double The Double value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putDouble("KEY", 10.5, Expiry.FOREVER)

putDoubleArray

Stores a Array<Double> value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Array<Double> The Array<Double> value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putDoubleArray("KEY", arrayOf(0.1, 10.5), Expiry.FOREVER)

putInt

Stores a Int value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Int The Int value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putInt("KEY", 10, Expiry.FOREVER)

putIntArray

Stores a Array<Int> value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Array<Int> The Array<Int> value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putIntArray("KEY", arrayOf(100, Int.MAX_VALUE), Expiry.FOREVER)

putJsonArray

Stores an org.json.JSONArray value at the given key.

Parameters Type Description
key String The name of the variable being stored
value JSONArray The org.json.JSONArray value to be store
expiry Expiry (Optional) The Expiry time of this variable
val my_list = new JSONArray();
my_list.put("value_1");
my_list.put("value_2");
tealium.dataLayer.putJsonArray("KEY", my_list, Expiry.FOREVER);

putJsonObject

Stores an org.json.JSONObject value at the given key.

Parameters Type Description
key String The name of the variable being stored
value JSONObject The org.json.JSONObject value to be store
expiry Expiry (Optional) The Expiry time of this variable
val my_obj = new JSONObject();
my_obj.put("key", "value");
tealium.dataLayer.putJsonObject("KEY", my_obj, Expiry.FOREVER);

putLong

Stores a Long value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Long The Long value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putLong("KEY", Long.MAX_VALUE, Expiry.FOREVER)

putLongArray

Stores a Array<Long> value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Array<Long> The Array<Long> value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putLongArray("KEY", arrayOf(1000L, Long.MAX_VALUE), Expiry.FOREVER)

putString

Stores a String value at the given key.

Parameters Type Description
key String The name of the variable being stored
value String The String value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putString("KEY", "String Value", Expiry.FOREVER)

putStringArray

Stores a Array<String> value at the given key.

Parameters Type Description
key String The name of the variable being stored
value Array<String> The Array<String> value to be store
expiry Expiry (Optional) The Expiry time of this variable
tealium.dataLayer.putStringArray("KEY",
    arrayOf("String 1", "String 2"), Expiry.FOREVER)

remove

Removes the value stored at the given key

Parameters Type Description
key String The name of the variable to be removed
tealium.dataLayer.remove("KEY")
"CurrentVisit "
Previous
CurrentVisit
Next
Lifecycle
"Lifecycle"

 

Was this article helpful?

This page was last updated: December 14, 2021      

Thank you for your feedback!

Table of Contents

  • Class: DataLayer
    • all
    • clear
    • contains
    • count
    • get
    • getBoolean
    • getBooleanArray
    • getDouble
    • getDoubleArray
    • getInt
    • getIntArray
    • getJsonArray
    • getJsonObject
    • getLong
    • getLongArray
    • getString
    • getStringArray
    • keys
    • putBoolean
    • putBooleanArray
    • putDouble
    • putDoubleArray
    • putInt
    • putIntArray
    • putJsonArray
    • putJsonObject
    • putLong
    • putLongArray
    • putString
    • putStringArray
    • remove
  • Platforms
  • Partners
  • Forums
  • Mobile
  • Getting Started
  • Remote Commands
  • Android (Java)
  • Android (Kotlin)
  • Cordova 1.x
  • Cordova 2.x
  • Flutter 1.x
  • Flutter 2.x
  • iOS (Objective-C)
  • iOS (Swift) 1.x
  • iOS (Swift) 2.x
  • NativeScript
  • React Native 1.x
  • React Native 2.x
  • Unity 1.x
  • Unity 2.x
  • Xamarin 1.x
  • Xamarin 2.x
  • Web
  • Getting Started
  • Adobe Launch
  • AMP
  • Angular
  • Google Tag Manager
  • JavaScript (Web)
  • Server
  • C#
  • HTTP API
  • Java
  • Node
  • Python
  • Roku
  • Ruby