About Tags

About Tags

Contents

Introduction

The Android SDK allows you to retrieve, create, and delete tags. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with tags.

Example

setTags

  1. Add Cloud SDK for Android to an existing or a new Android project.
  2. Initialize the CloudAPI class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.
  3. Authorize the application by calling CloudAPI#authorize().
  4. Create a tag by calling CloudAPI#setTags.

Code Sample

try {
	ItemList<Photo> itemListPhotos = cloudAPI.getPhotos(context, SortType.VERSION_CREATED.setOrder(SortType.SortOrder.DESC));
	Photo photo = itemListPhotos.getItem(0);
	String tags = "New Tag";
    String newTags = cloudAPI.setTags(context, photo.getUri(), tags);
    Log.d("Set Tags", "Tags: " + newTags);
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Set Tags", "User not authorized, please call CloudAPI#authorize()");
    }
}

deleteTags

deleteTags method allows you to delte tags for a file or folder.

  1. Add Cloud SDK for Android to an existing or a new Android project.
  2. Initialize the CloudAPI class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.
  3. Authorize the application by calling CloudAPI#authorize().
  4. Use code samples listed below to delete tags.

Code Sample

try {
	ItemList<Photo> itemListPhotos = cloudAPI.getPhotos(context, SortType.VERSION_CREATED.setOrder(SortType.SortOrder.DESC));
	Photo photo = itemListPhotos.getItem(0);
    cloudAPI.deleteTags(context, photo.getUri());
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Delete Tags", "User not authorized, please call CloudAPI#authorize()");
    }
}

getTags

getTags method allows you to retrieve tags for a file or folder.

  1. Add Cloud SDK for Android to an existing or a new Android project.
  2. Initialize the CloudAPI class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.
  3. Authorize the application by calling CloudAPI#authorize().
  4. Use code samples listed below to retrieve a list of tags for a file or folder.

Code Sample

try {
	ItemList<Photo> itemListPhotos = cloudAPI.getPhotos(context, SortType.VERSION_CREATED.setOrder(SortType.SortOrder.DESC));
	Photo photo = itemListPhotos.getItem(0);
	String path = photo.getParentPath() + "/" + photo.getName();
    String tags = cloudAPI.getTags(context, path);
    Log.d("Get Tags", "Tags: " + tags);
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Get Tags", "User not authorized, please call CloudAPI#authorize()");
    }
}

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.