NullPoointerException pulling images from cash using hascode?
<p>I have a String list of Strings here</p>

<pre><code> public String [] myRemoteImages = {imageUrl,imageUrl2,imageUrl3,imageUrl4,imageUrl5,imageUrl6,imageUrl7};
</code></pre>

<p>In my postexecute after retrieving the strings i log them to make sure they arent null.
Then i </p>

<pre><code>protected void onPostExecute(Void notUsed){
                    Log.e("URLS", imageUrl + imageUrl2 + imageUrl3 + imageUrl4 + imageUrl5 + imageUrl6 + imageUrl7);



                         adapter=new LazyAdapter(MainMenu.this, myRemoteImages);
                          ((Gallery) findViewById(R.id.gallery))
                          .setAdapter(adapter);

                          adapter.notifyDataSetChanged();
</code></pre>

<p>after they are retrieved i create a instance of a BaseAdapter that takes two parameters and set it to a Gallery.</p>

<p>Here is my Adapter.</p>

<pre><code>  public LazyAdapter(Activity a, String[] d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.lazyitemt, null);


    ImageView image=(ImageView)vi.findViewById(R.id.imageView);

    image.setLayoutParams(new LinearLayout.LayoutParams(250, 250));
    imageLoader.DisplayImage(data[position], activity, image);
    return vi;
}
</code></pre>

<p>}</p>

<p>Now i get a NullPointer Exception at this method inside my FileCache  class..It tried to check if the the images are in cache. But i get an error at </p>

<p>public File getFile(String url){</p>

<pre><code>//Error here Nullpointer.
    String filename=String.valueOf(url.hashCode());
    File f = new File(cacheDir, filename);
    return f;

}
</code></pre>

<p>I am supplying the String list with url's i dont know why it is coming out with a nullpointer exception?</p>

<p>I call getBitmap like this.</p>

<pre><code> private Bitmap getBitmap(String url) 
{
    File f=fileCache.getFile(url);

    //from SD cache
    Bitmap b = decodeFile(f);
    if(b!=null)
        return b;

    //from web
    try {
        Bitmap bitmap=null;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        InputStream is=conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();
        bitmap = decodeFile(f);
        return bitmap;
    } catch (Exception ex){
       ex.printStackTrace();
       return null;
    }
}
</code></pre>
