title: DLNA/UPNP - Get all non-media files
body: <p>I am new in working with UpNp and DLNA. I am using cling library and DLNA code from <a href="https://github.com/offbye/DroidDLNA" rel="nofollow noreferrer">here</a>. In this code, everything working perfectly but my need is something else. It is giving me all media folders(Videos, Audio and Images) from selected device in network. But what I want is non media files from selected device on the network i.e., .docx, .srt, .txt etc. </p>
  
  <p>Here is some code portion:</p>
  
  <pre><code> upnpService.getControlPoint().execute(
                  new ContentBrowseActionCallback(ContentActivity.this,
                          service, createRootContainer(service), mContentList,
                          mHandler));
  </code></pre>
  
  <p>Root Container:</p>
  
  <pre><code> protected Container createRootContainer(Service service) {
          Container rootContainer = new Container();
          rootContainer.setId("0");
          rootContainer.setTitle("Content Directory on "
                  + service.getDevice().getDisplayString());
          Log.e("createRootContainer", "service.getDevice().getDisplayString() : " + service.getDevice().getDisplayString());
          return rootContainer;
      }
  </code></pre>
  
  <p>ContentBrowseActionCallback:</p>
  
  <pre><code>public class ContentBrowseActionCallback extends Browse {
  
      private static Logger log = Logger
              .getLogger(ContentBrowseActionCallback.class.getName());
  
      private Service service;
  
      private Container container;
  
      private ArrayList&lt;ContentItem&gt; list;
  
      private Activity activity;
  
      private Handler handler;
  
      public ContentBrowseActionCallback(Activity activity, Service service,
                                         Container container, ArrayList&lt;ContentItem&gt; list, Handler handler) {
          super(service, container.getId(), BrowseFlag.DIRECT_CHILDREN, "*", 0,
                  null, new SortCriterion(true, "dc:title"));
          this.activity = activity;
          this.service = service;
          this.container = container;
          this.list = list;
          this.handler = handler;
      }
  
      public void received(final ActionInvocation actionInvocation,
                           final DIDLContent didl) {
          log.fine("Received browse action DIDL descriptor, creating tree nodes");
          activity.runOnUiThread(new Runnable() {
              public void run() {
                  try {
                      list.clear();
                      // Containers first
                      for (Container childContainer : didl.getContainers()) {
                          Log.e("Item", "childContainer : " + childContainer.getTitle());
                          log.fine("add child container "
                                  + childContainer.getTitle());
                          list.add(new ContentItem(childContainer, service));
                      }
                      // Now items
                      for (Item childItem : didl.getItems()) {
                          Log.e("Item", "childItem : " + childItem.getTitle());
                          log.fine("add child item" + childItem.getTitle());
                          list.add(new ContentItem(childItem, service));
                      }
                  } catch (Exception ex) {
                      log.fine("Creating DIDL tree nodes failed: " + ex);
                      actionInvocation.setFailure(new ActionException(
                              ErrorCode.ACTION_FAILED,
                              "Can't create list childs: " + ex, ex));
                      failure(actionInvocation, null);
                      handler.sendEmptyMessage(ContentActivity.CONTENT_GET_FAIL);
                  }
                  ConfigData.listPhotos.clear();
                  Iterator iterator = didl.getItems().iterator();
                  while (iterator.hasNext()) {
                      Item item = (Item) iterator.next();
                      Log.e("received", "item.getTitle() : " + item.getTitle());
                      ContentItem contentItem = new ContentItem(item,
                              ContentBrowseActionCallback.this.service);
                      if ((contentItem.getItem().getTitle().toString() != null)
                              &amp;&amp; (contentItem.getItem().getResources() != null)) {
  
                          List list = contentItem.getItem().getResources();
                          if ((list.size() != 0)
                                  &amp;&amp; (((Res) list.get(0)).getProtocolInfo() != null)
                                  &amp;&amp; (((Res) list.get(0)).getProtocolInfo()
                                  .getContentFormat() != null)) {
                              Log.e("received", "list.get(0).getProtocolInfo() : " + ((Res) list.get(0)).getProtocolInfo());
                              Log.e("received", "list.get(0).getProtocolInfo().getContentFormat() : " + ((Res) list.get(0)).getProtocolInfo().getContentFormat());
                              Log.e("received", "list.get(0).getProtocolInfo().getContentFormat().substring() : " + ((Res) list.get(0)).getProtocolInfo().getContentFormat().substring(0,
                                      ((Res) list.get(0))
                                              .getProtocolInfo()
                                              .getContentFormat()
                                              .indexOf("/")));
                              if (((Res) list.get(0))
                                      .getProtocolInfo()
                                      .getContentFormat()
                                      .substring(
                                              0,
                                              ((Res) list.get(0))
                                                      .getProtocolInfo()
                                                      .getContentFormat()
                                                      .indexOf("/"))
                                      .equals("image")) {
                                  ConfigData.listPhotos
                                          .add(new ContentItem(
                                                  item,
                                                  ContentBrowseActionCallback.this.service));
                              } else if (((Res) list.get(0))
                                      .getProtocolInfo()
                                      .getContentFormat()
                                      .substring(
                                              0,
                                              ((Res) list.get(0))
                                                      .getProtocolInfo()
                                                      .getContentFormat()
                                                      .indexOf("/"))
                                      .equals("audio")) {
                                  ConfigData.listAudios
                                          .add(new ContentItem(
                                                  item,
                                                  ContentBrowseActionCallback.this.service));
                              } else {
                                  Log.e("received", "item : " + item.getTitle());
                                  ConfigData.listVideos
                                          .add(new ContentItem(
                                                  item,
                                                  ContentBrowseActionCallback.this.service));
                              }
                          }
                      }
                  }
                  handler.sendEmptyMessage(ContentActivity.CONTENT_GET_SUC);
              }
          });
      }
  
      public void updateStatus(final Status status) {
      }
  
      @Override
      public void failure(ActionInvocation invocation, UpnpResponse operation,
                          final String defaultMsg) {
      }
  }
  </code></pre>
  
  <p>I googled a lot about this point but nothing in hand. I got few ideas about container id and how it works.</p>
  
  <p>Please let me know how to achieve this scenario. I also don't have much idea about how DLNA and UPNP works. Please also help me to understand DLNA and UPNP better.</p>
  
  <p>Thank You!</p>