title: Creating TOpenDialog manually in C++ Builder XE 8 (firemonkey)
body: <p>I am using C++ Builder XE8. As the <code>TOpenDialog</code> doesn't work on Android, I am trying to make such thing myself. My logic is very simple. It'll start to check file and folders from "/storage" and show all items on <code>TListView</code>.  If I touch a folder (name) it'll open that folder and if I touch a file, it should show the name on a label. So I assigned a function to <code>TListView</code>'s  <code>OnItemClick</code> event.</p>
  
  <p>Here is code. fpath is String, Label1 is showing current folder and Label2 is showing selected file.</p>
  
  <pre><code>void __fastcall TForm1::lviewitemclck(TObject * const Sender, TListViewItem * const AItem)
  {
  if (AItem-&gt;Text == "&lt;&lt; BACK") {
          if (!fpath.LastDelimiter("/") == 0) {
              fpath = fpath.SubString(0, fpath.LastDelimiter("/"));
  
              Label1-&gt;Text = fpath;
              Form1-&gt;showfiles(fpath);
          }
     }
     else if ( DirectoryExists(fpath+ AItem-&gt;Text)) {
              fpath = fpath+ AItem-&gt;Text;
  
              Label1-&gt;Text = fpath;
              Form1-&gt;showfiles(fpath);
      }
      else if (FileExists(fpath+ AItem-&gt;Text)) {
           Label2-&gt;Text ="File: "+ fpath+ AItem-&gt;Text;
     }
  }
  </code></pre>
  
  <p>Below is the code of function to scan for files &amp; folders and show them. stringlist is TStringList.</p>
  
  <pre><code>void __fastcall TForm1::showfiles (String path)
  {
  
  TSearchRec sr;  // for scaning files and folders
  TSearchRec fr;  // to check whether the folder is accessible or not.
  
  if (FindFirst(path+"/*", faAnyFile, sr) == 0)
      {
          stringlist-&gt;Clear();
          stringlist-&gt;Add("&lt;&lt; BACK");  // being used to replace the ".."
  
          do{
              if(sr.Name != "."   &amp;&amp;   sr.Name != ".."){
  
                      if (DirectoryExists(path+"/"+sr.Name)) {
                          if (FindFirst(path+"/"+sr.Name+"/*", faAnyFile, fr) == 0) { // to check if the folder is accessible
                              stringlist-&gt;Add("/"+ sr.Name);
                          }
                          FindClose(fr);
                      }
                      else{
                          stringlist-&gt;Add("/"+ sr.Name);
                      }
  
              }
          }  while (FindNext(sr) == 0);
      }
      FindClose(sr);
  
    stringlist-&gt;Sort();
  
    Form1-&gt;Item-&gt;Free();
  
    Form1-&gt;ListView1-&gt;BeginUpdate();
  
    Form1-&gt;ListView1-&gt;ClearItems();
  
  for( int i =0;i&lt; stringlist-&gt;Count; i++){
       Form1-&gt;Item = Form1-&gt;ListView1-&gt;Items-&gt;Add();
       Form1-&gt;Item-&gt;Text = stringlist-&gt;Strings[i];
  }
   Form1-&gt;ListView1-&gt;EndUpdate();
  
  }
  </code></pre>
  
  <p>Here the problem is, if I use <code>ListView1-&gt;ClearItems()</code> in TForm1::showfiles it shows me an error saying "Access violation at address (random no), accessing address 00000009". And if I dont use <code>ClearItems()</code> it just add more lines with already existed lines. I am a beginer, so I dont know where I am doing wrong. </p>