title: Convert a string which contains uri paths to a arraylist<uri>
body: <p>I am creating a notepad programm where the user can add images to his notes . When he creates a new note and picks a few images their paths(uri) are stored in an arraylist which is converted to a xml tag (string type conversion) . When the user wants to open a created note the selected images from before are displayed in a gridview. However when i try to convert the string tag from the xml file to an arraylist so the imageadapter can put them in the grid view i am getting errors about conversion types .
  <em>edit</em> the error i get is -java.lang.String cannot be cast to android.net.Uri-</p>
  
  <p>The adapter is this </p>
  
  <pre><code>`private Context ctx;
      private int pos;
      private LayoutInflater inflater;
      private ImageView ivGallery;
      ArrayList&lt;Uri&gt; mArrayUri;
      public GalleryAdapter(Context ctx, ArrayList&lt;Uri&gt; mArrayUri) {
  
  
          this.ctx = ctx;
          this.mArrayUri = mArrayUri;
      }
  
      @Override
      public int getCount() {
          return mArrayUri.size();
      }
  
      @Override
      public Object getItem(int position) {
          return mArrayUri.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          pos = position;
          inflater = (LayoutInflater) ctx
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          View itemView = inflater.inflate(R.layout.gv_item, parent, false);
  
          ivGallery = (ImageView) itemView.findViewById(R.id.ivGallery);
  
          ivGallery.setImageURI(mArrayUri.get(position));
  
          return itemView;
      }`
  </code></pre>
  
  <p>and the way i try to convert them to array and show them in the grid view is this</p>
  
  <pre><code>`  String Paths = userData.get(1);
  
  
              ArrayList mArrayUri = new ArrayList&lt;&gt;(Arrays.asList(Paths.split(",")));
              galleryAdapter = new GalleryAdapter(getApplicationContext(),mArrayUri);
              gvGallery.setAdapter(galleryAdapter);
              gvGallery.setVerticalSpacing(gvGallery.getHorizontalSpacing());
              ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) gvGallery
                      .getLayoutParams();
              mlp.setMargins(0, gvGallery.getHorizontalSpacing(), 0, 0);
  
  `
  </code></pre>
  
  <p>The xml creation code is this</p>
  
  <pre><code>` xmlSerializer.startDocument("UTF-8", true);
              xmlSerializer.startTag(null, "userData");
              xmlSerializer.startTag(null,"Text");
              xmlSerializer.text(NoteText);
              xmlSerializer.endTag(null, "Text");
              xmlSerializer.startTag(null,"Image Paths");
              xmlSerializer.text(String.valueOf(Gallery.ImagePaths));
              xmlSerializer.endTag(null,"Image Paths" );
              xmlSerializer.endTag(null, "userData");
              xmlSerializer.endDocument();`
  </code></pre>