FATAL EXCEPTION: main in a program to search for pdf files in sd card
<p>debug.java</p>

<pre><code> package com.himanshu;

    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;

    public class BookShelfDebugActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Log.i("debug","qwert111111");

            FileWalker fw=new FileWalker();
            fw.Walker("/");
            String a=fw.ListPDF[0].getName();
            String b=fw.ListPDF[1].getName();

            Log.i("debug",a);
                    Log.i("debug",b);



        }
    }
</code></pre>

<p>FileWalker.java</p>

<pre><code> package com.himanshu;

    import java.lang.String;
    import java.io.File;
    import android.app.ProgressDialog;
    import android.content.Context;


    public class FileWalker  {

        public File[] ListPDF;
        public int count = 0;
        public String Path;
        public Context context;

    public void Walker(String Path){
            File root = new File(Path);
            File [] List = root.listFiles();
            for(File f :List){
                if(f.isDirectory()){
                    Walker(f.getAbsolutePath());
                }
                else{
                    if(f.getName().endsWith(".pdf")){
                        ListPDF[count] = f;
                        count++;
                    }
                }
            }
        }
    }
</code></pre>

<p>errors</p>

<pre><code>02-15 20:05:26.903: E/AndroidRuntime(1313): FATAL EXCEPTION: main
02-15 20:05:26.903: E/AndroidRuntime(1313): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.himanshu/com.himanshu.BookShelfDebugActivity}: java.lang.NullPointerException
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.os.Looper.loop(Looper.java:123)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread.main(ActivityThread.java:4627)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at java.lang.reflect.Method.invokeNative(Native Method)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at java.lang.reflect.Method.invoke(Method.java:521)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at dalvik.system.NativeStart.main(Native Method)
02-15 20:05:26.903: E/AndroidRuntime(1313): Caused by: java.lang.NullPointerException
02-15 20:05:26.903: E/AndroidRuntime(1313):     at com.himanshu.FileWalker.Walker(FileWalker.java:35)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at com.himanshu.FileWalker.Walker(FileWalker.java:37)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at com.himanshu.BookShelfDebugActivity.onCreate(BookShelfDebugActivity.java:16)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-15 20:05:26.903: E/AndroidRuntime(1313):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
</code></pre>

<p>i'm just trying to find all the pdf files in the sd card.. but the program is not working...
i  copied two pdf files from desktop to the AVD's /data/mnt/sdcard and tried to print their names on logcat..
please help me out...</p>
