Skip To Content

Access portal content

In this topic

Portals such as ArcGIS Online and Portal for ArcGIS can store many types of data. Perhaps the type most commonly used by apps is a web map—a JSON description of the data in a map, along with other display and behavioral properties. Other types include tile packages, feature collections, and services. Some types, such as globe documents and map templates, may only be relevant to desktop systems. Although you can access these items using the API, you may not be able to use them on a mobile device.

The PortalItemobject represents an individual item stored on a portal. Each item includes the following:

  • Metadata, such as a unique identifier (ID), title, summary, description, thumbnail image, and tags
  • Binary or text-based data—for example, the JSON that defines a web map or a feature collection, or a URL pointing to a map service, or the binary data of a tile package or shapefile

Web page showing properties of a portal item including the item ID

Apps use portal items in different ways. They may show a user a range of items from a portal by combining the title, thumbnail image, and other metadata. This approach is often used to allow users to browse web maps, basemaps, or map services, and identify the item to work with. If a user selects an item, the app may then download the data stored in the portal item, for example, by opening and displaying a web map in a map, or downloading a tile package. Apps sometimes access items directly by ID if a specific item should always be used.

The portal API cannot change any of the fields of a portal item or group; refer to the REST API for information on the calls you can make through REST to make portal changes.

You access the content of a portal item differently depending on its type. Below you can find examples of accessing different types of portal items. For more information on connecting to a portal, see Access the ArcGIS platform. To find out how you can allow apps to browse or search for items and groups, see Search for content.

Display a web map by ID

A very common task is to display a web map from a portal. Web maps are stored as portal items and can be opened by using the ID of the item, along with the URL of the portal. If the map is not public (for example, if it is shared only with a specific group), you also need to pass in valid credentials with permission to view the map. See Access the ArcGIS platform for more information on accessing secured items.

The code below creates a MapView from a URL consisting of the portal URL and the portal item ID taken directly from a portal item (this could alternatively be hard coded). UserCredentials of a user with access rights to the web map are also passed in to the constructor.

String webmapUrl = String.format("%s/item/id=%s", portal.getUrl(), item.getItemId());
MapView mapViewFromUrl = new MapView(context, webmapUrl, credentials, null, null);

If defining your MapView within an XML layout, you can also hard code the URL to use, as shown below. This might be useful when testing, but is not a reliable approach for a production app.


Open a web map

You can also create an object that represents a web map without needing to display it immediately. From this, you could find out more about the contents of the map before displaying it—for example, getting the basemap, operational layers, bookmarks, and initial extent.

// Create a WebMap without displaying it.
WebMap webMap = WebMap.newInstance("1966ef409a344d089b001df85332608f");
for(Bookmark bookmark : webMap.getBookmarks()) {
  Envelope env = bookmark.getExtent();
  // Use bookmarks as required.
// Pass a WebMap to the MapView constructor overload to display it.
MapView mapViewFromWebmap = new MapView(context, webMap, null, null);

If the item cannot be found, for example, if the item owner has unshared or deleted it, then an exception will be thrown, so ensure you have exception handling code in place.


Remember that the credentials must be for a valid user with access to the item.

Find information about any portal item by ID

You can use the ID of any item stored in a portal to access it, and also to find its fields—properties such as its title, description, thumbnail image, owner, and any ratings or comments added by portal users. You can also find out the type of data it contains.

The code below creates a PortalItem object representing a web map, and then finds the title and the date it was last modified.

PortalItem item = PortalItem.fetchItem(portal, "1966ef409a344d089b001df85332608f");
Date modified = new Date(item.getModified());
String itemDetails = String.format("%s was last modified on %tA, %te of %tB", item.getTitle(), modified, modified, modified);


The thumbnail of a portal item, along with the ratings and data, is not returned from the portal when you initially create the item, in order to reduce the network traffic and memory requirements. See the section below on how to access these properties.

Fetch thumbnails of items

When you create a portal item object, not all information associated with it is immediately returned. This allows you to work with the item using a minimum amount of memory and delay fetching the larger pieces of data unless, or until, you really need them. Information you need to fetch, if required, includes thumbnail images, ratings and comments, item data, group memberships, and user folder contents.

The code below shows how to fetch the thumbnail image from a portal item and convert it to a Bitmap. You can then convert this to a BitmapDrawable to use it in your layout, as shown below, ensuring this is performed on the UI thread.

if (item.getThumbnailFileName() != null) {
  byte[] itemThumbnailData = item.fetchThumbnail();
  if ((itemThumbnailData != null) && (itemThumbnailData.length > 0)) {
    Bitmap itemThumbnail = BitmapFactory.decodeByteArray(itemThumbnailData, 0, itemThumbnailData.length);
    final BitmapDrawable drawable = new BitmapDrawable(getApplicationContext().getResources(), itemThumbnail);
    if (drawable != null) {
      myActivity.this.runOnUiThread(new Runnable() {
        public void run() {
          if (mImageView != null) {

The same applies to the thumbnails of other classes, like users, groups, and organizations. Use the PortalInfo.fetchOrganizationThumbnail, PortalInfo.fetchPortalThumbnail, PortalUser.fetchThumbnail, and PortalGroup.fetchThumbnail methods. Check the PortalUser, PortalItem, and PortalGroup classes for other similar fetch methods.

Access item data

Portal items that represent files, such as tile packages, images, documents, PDF files, and so on, can be opened, downloaded, and then stored or opened in your app or in another app. As in the previous example, you will need to specifically fetch the data of a portal item after you create it. Use the fetchData method to do this.

The following example creates a PortalItem from a Portal and an item ID string referring to a tile package, and then calls the fetchData method. Note that as fetchData must not be called on the UI thread (as it performs network communications), this is done in the doInBackground method of a task. Once the download is complete, in the onPostExecute method of the task (in the main thread), the file is then added as an ArcGISLocalTiledLayer to a map.

class DataFetchTask extends AsyncTask<String, Void, String> {
	protected String doInBackground(String... arg0) {	
		String itemId = arg0[0];
		String filePath = "";
		  // Fetch the portal item by ID, and the data, passing in a Portal with an 
      // authenticated user with access to the item.
		  PortalItem item = PortalItem.fetchItem(portal, itemId);
		  filePath = Environment.getExternalStorageDirectory().getPath() + "/download/" + item.getName();
		  InputStream inputStream = item.fetchData();
		  // Save the data to a file.
		  OutputStream outputStream = new FileOutputStream(filePath);
       byte[] buf = new byte[4096];
       int len, size = 0;
       while ((len = != -1) {
         outputStream.write(buf, 0, len);
         size += len;
		} catch (Exception e) {
			Log.e(TAG, "Exception while downloading item: " + e.getMessage());
		return filePath;
	protected void onPostExecute(String result) {
	  // Add the file as a layer to the map.
		File file = new File(result);
		if (file.exists()) {
		  ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer(result);

Fetch a user's content

Many apps present a list of maps or other items that belong to the current user. Users can create folders within their portal accounts to help organize their work. Apps should respect the user's view of their content and present the list of folders to the user, allowing the user to choose which folder to look at in detail.

It's easy to get all the portal items owned by the authenticated user (that represent the content and services items created by that user).

A PortalUser represents information about a user, and from this you can retrieve all of the items and folders (represented by PortalFolder) owned by the user. The code below iterates all of the items belonging to the authenticated user of the portal variable that are in the default (or root) user folder, using the PortalUserContent returned from PortalUser.fetchContent. Also, each folder and its contents are iterated, using fetchFolders, and all of the folders and the items each folder contains.

PortalUser user = portal.fetchUser();
PortalUserContent rootContent = user.fetchContent();
for (PortalItem item : rootContent.getItems())
  // Iterate items in root folder…

// Iterate folders.
for (PortalFolder folder : rootContent.getFolders())
  // Iterate items in the folder…
  PortalUserContent folderContent = user.fetchContentInFolder(folder.getFolderId());
  for (PortalItem folderItem : folderContent.getItems())
    // Iterate items in root folder…

More typically, you may write an Adapter class to show PortalFolders and PortalItems in a ListView to a user (perhaps showing the title, thumbnail, and summary), and add the values from getItems and getFolders to those adapters. You can see an example of a PortalItemListAdapter, showing the title and thumbnail image from a portal item, in the Portal Featured User Groups sample.


As seen in the code above, user content is another example of information that you must explicitly fetch, like portal item thumbnails and content.

To get items shared with the current user, or items owned by a different user, you need to search for content.

List the groups a user belongs to

Groups can be configured in different ways—some groups are open to all users; some are only accessible by invitation; and for others, any user can request to join. The groups to which the authenticated user belongs can be accessed, and for any group, the identities of the members can be found.

The PortalGroup class represents a group. You can get a list of the groups a user belongs to by calling the PortalUser.fetchGroups method. Use another fetch method, fetchAndUpdateMembership, to retrieve the users in each group—after that, you can get the members from the getUsers method.

PortalUser user = portal.fetchUser();
for (PortalGroup group : user.getGroups()) {
  // Find out the membership of each group.
  if (group.fetchAndUpdateMembership())
    List<String> groupUsers = group.getUsers();
    Log.i(TAG, String.format("Group %s members are %s", 
      group.getTitle(), TextUtils.join(",", groupUsers.toArray())));

From the group, you can find out if membership is by invitation only (using PortalGroup.isInvitationOnly), and if the user can share items with the group (using PortalGroup.isViewOnly). To find out the items currently shared with a specific group, you need to use the group ID to search for content in a group. To find other groups, for example, those relating to a keyword (tag), you can search for groups, or find the featured groups of a portal.


You can find examples of working with a portal and searching for content in the Portal Featured User Groups sample.