<commit_before>---
layout: page
title: Setting up Offline Playback on Android Devices
subcat: Android Version 3.0
weight: 412
---

[![Android](https://img.shields.io/badge/Android-Supported-green.svg)](https://github.com/kaltura/playkit-android)

This article describes how to implement offline playback in Playkit SDK on Android devices. 

First, download the media you wish to play. If you are looking for a good download manager you can use [this](https://github.com/kaltura/playkit-dtg-android) one. In general the most complex part of the playback in offline is managing the DRM content license, but we've already covered that issue for you.

## Registering the Asset  

First, you'll need to create an instance of the [LocalAssetManager](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalAssetsManager.java).

Note that you have two constructors for this object; however, the first constructor only receives Android context.

>**Important!** The context must be the Android Application context.

  ```
  //Create new instance of localAssetManager with default implementatoin of LocalDrmStorage.
  LocalAssetsManager localAssetsManager = new LocalAssetsManager(context);
  ```

Next, accept an additional parameter of type [LocalDrmStorage](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalDrmStorage.java).

  ```
  //Create new instance of localAssetManager with custom implementatoin of LocalDrmStorage.
  LocalAssetsManager localAssetsManager = new LocalAssetsManager(context, YourLocalDrmStorage);
  ```

In first constructor, we implicitly implemented the [LocalDrmStorage](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalDrmStorage.java) interface in the DefaultLocalDrmStorage class (which is actually an inner class of the LocalAssetsManager). In the second constructor, you can have your own implementation of this interface. You can read more about the LocalDrmStorage later in this section. For now, let's use the default constructor.

Register the asset to the LocalAssetsManager. Note that you'll have to be ***Online*** while doing so.

  ```
  //This listener will notify you about success/fail of the registration process.
  LocalAssetsManager.AssetRegistrationListener registrationListener = new LocalAssetsManager.AssetRegistrationListener() {
                    @Override
                    public void onRegistered(String assetPath) {
                        Log.i("TAG", "asset registered " + assetPath);
                    }

                    @Override
                    public void onFailed(String assetPath, Exception error) {
                        Log.e("TAG", "asset onFailed " + assetPath + " ex " + error.getMessage());
                    }
                });

  //Actually register asset.<commit_msg>Update Offline-Android.md<commit_after>---
layout: page
title: Setting up Offline Playback on Android Devices
subcat: Android Version 3.0
weight: 411
---

[![Android](https://img.shields.io/badge/Android-Supported-green.svg)](https://github.com/kaltura/playkit-android)

This article describes how to implement offline playback in Playkit SDK on Android devices. 

First, download the media you wish to play. If you are looking for a good download manager you can use [this](https://github.com/kaltura/playkit-dtg-android) one. In general the most complex part of the playback in offline is managing the DRM content license, but we've already covered that issue for you.

## Registering the Asset  

First, you'll need to create an instance of the [LocalAssetManager](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalAssetsManager.java).

Note that you have two constructors for this object; however, the first constructor only receives Android context.

>**Important!** The context must be the Android Application context.

  ```
  //Create new instance of localAssetManager with default implementatoin of LocalDrmStorage.
  LocalAssetsManager localAssetsManager = new LocalAssetsManager(context);
  ```

Next, accept an additional parameter of type [LocalDrmStorage](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalDrmStorage.java).

  ```
  //Create new instance of localAssetManager with custom implementatoin of LocalDrmStorage.
  LocalAssetsManager localAssetsManager = new LocalAssetsManager(context, YourLocalDrmStorage);
  ```

In first constructor, we implicitly implemented the [LocalDrmStorage](https://github.com/kaltura/playkit-android/blob/develop/playkit/src/main/java/com/kaltura/playkit/LocalDrmStorage.java) interface in the DefaultLocalDrmStorage class (which is actually an inner class of the LocalAssetsManager). In the second constructor, you can have your own implementation of this interface. You can read more about the LocalDrmStorage later in this section. For now, let's use the default constructor.

Register the asset to the LocalAssetsManager. Note that you'll need to be ***Online*** while doing so.

  ```
  //This listener will notify you about success/fail of the registration process.
  LocalAssetsManager.AssetRegistrationListener registrationListener = new LocalAssetsManager.AssetRegistrationListener() {
                    @Override
                    public void onRegistered(String assetPath) {
                        Log.i("TAG", "asset registered " + assetPath);
                    }

                    @Override
                    public void onFailed(String assetPath, Exception error) {
                        Log.e("TAG", "asset onFailed " + assetPath + " ex " + error.getMessage());
                    }
                });

  //Actually register asset.
{'fraction_non_alphanumeric': 0.08439108061749571, 'fraction_numerical': 0.0017152658662092624, 'mean_word_length': 3.649920255183413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '370679', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1463, 'n_words': 528}