About Virtual Folders

About Virtual Folders

Contents

Introduction

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

Example

createVirtualFolder

createVirtualFolder method allows you to create a virtual 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. Create a virtual folder by calling CloudAPI#createVirtualFolder.

Code Sample

try {
	VirtualFolder virtualFolder = cloudAPI.createVirtualFolder((context, folderName);
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Create Virtual Folder", "User not authorized, please call CloudAPI#authorize()");
    }
}

deleteVirtualFolder

deleteVirtualFolder method allows you to delte a virtual 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 a virtual folder.

Code Sample

try {
	boolean success = cloudAPI.deleteVirtualFolder((context, "folder name", false);
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Delete Virtual Folder", "User not authorized, please call CloudAPI#authorize()");
    }
}

renameVirtualFolder

renameVirtualFolder method allows you to rename a virtual 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 rename a virtual folder.

Code Sample

try {
	VirtualFolder virtualFolder = cloudAPI.renameVirtualFolder((context, "current folder name", "new folder name");
} catch (CloudAPIException cloudAPIException) {
    if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) {
		Log.d("Rename Virtual Folder", "User not authorized, please call CloudAPI#authorize()");
    }
}

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