Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7498855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:37:12+00:00 2026-05-29T19:37:12+00:00

debug.java package com.himanshu; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class BookShelfDebugActivity extends Activity

  • 0

debug.java

 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);



        }
    }

FileWalker.java

 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++;
                    }
                }
            }
        }
    }

errors

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)

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:37:14+00:00Added an answer on May 29, 2026 at 7:37 pm

    Well, one thing jumps out. You’re declaring an array but never allocating an array, then assigning items to the array.

    public File[] ListPDF;
    
    ...
    
    ListPDF[count] = f;
    

    That’ll crash fairly hard every time. Since this is an unbounded list of items, an ArrayList would work better.

    List<File> ListPDF = new ArrayList<File>();
    
    ...
    
    ListPDF.add(f);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is My Whole Code....... BroadcastExample.java package com.example.broadcast; > import android.app.Activity; import > android.content.Context;
I'm trying to package an Android app which uses RoboGuice. The .class files compile
What would be a nice testbed to debug JAVA APPLET based SCORM content package
I have a java class and I need to debug it (put breakpoints and
If on run/debug configuration, if I specify a launch activity, then my app runs
I know there's some JAVA_OPTS to set to remotely debug a Java program. What
I am trying to debug an issue involving a ClassCastException in Java. In the
I have developed some reusable android component which is basically a class . This
I have starting learning Java and android application development side-by-side. Currently, I a String-array
Any clue why my Android app is hanging on this code block when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.