title: Android - How to cast Object [] to File []
body: <p>I'm creating an app in android! I'm trying to pass File[] from my Main Activity class using this line of code:</p>
  
  <pre><code>File[] listFile;
  File file = new File(android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Eye Spy");
     if (file.isDirectory()) {
         listFile = (File[]) file.listFiles();
     }
  Intent i = new Intent();
  i.putExtra("images", listFile);
  </code></pre>
  
  <p>to my MapsActivity using this line of code:</p>
  
  <pre><code>listFile = (File[]) getIntent().getExtras().get("images");
  </code></pre>
  
  <p>But when I run the app, it displays an error message saying: </p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pathnrdo.eyespy1/com.example.pathnrdo.eyespy1.MapsActivity}: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.io.File[]</p>
  </blockquote>
  
  <p>What seems to be the problem? And how can i fix it? Thanks for your reply :)</p>