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 6121481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:47:20+00:00 2026-05-23T15:47:20+00:00

I have a FileBrowser activity that I got from AndDev site. The problem is

  • 0

I have a FileBrowser activity that I got from AndDev site. The problem is that it stopped working and it crashes, here is the logcat:

07-05 11:20:35.803: ERROR/AndroidRuntime(14706): FATAL EXCEPTION: main
07-05 11:20:35.803: ERROR/AndroidRuntime(14706): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {omar.quran1/omar.quran1.DataDownload}: java.lang.NullPointerException
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread.access$2000(ActivityThread.java:117)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.os.Looper.loop(Looper.java:130)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread.main(ActivityThread.java:3687)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at java.lang.reflect.Method.invokeNative(Native Method)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at java.lang.reflect.Method.invoke(Method.java:507)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at dalvik.system.NativeStart.main(Native Method)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706): Caused by: java.lang.NullPointerException
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at omar.quran1.DataDownload.dirSize(DataDownload.java:387)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at omar.quran1.DataDownload.CheckIfFilesAlreadyExist(DataDownload.java:372)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at omar.quran1.DataDownload.onActivityResult(DataDownload.java:310)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
07-05 11:20:35.803: ERROR/AndroidRuntime(14706):     ... 11 more

Here is what I do once the user chose the folder he wants:

         StatFs stat = new StatFs(currentDirectory.getAbsolutePath());
                stat.restat(currentDirectory.getAbsolutePath());
                long available = ((long) stat.getAvailableBlocks() * (long) stat.getBlockSize());


                if((available / 1048576)>120)
                {
                    Intent resultIntent = new Intent();
                    resultIntent.putExtra("FilePath", currentDirectory.getPath());
                    setResult(Activity.RESULT_OK, resultIntent);
                    finish();
                }

And on the caller activity:

@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) {     
  super.onActivityResult(requestCode, resultCode, data); 
  switch(requestCode) { 
    case 1: { 
      if (resultCode == Activity.RESULT_OK) { 
          PATH = data.getStringExtra("FilePath"); 

          if(CheckIfFilesAlreadyExist(PATH)) //check if the files are already there.
          {
              if(!PATH.contains("Quran"))
                      PATH+="/Quran/";
              Main.Main_PATH=PATH;
              Toast.makeText(mContext, "The files have been found", Toast.LENGTH_LONG).show();

              Intent returnIntent = new Intent();
              setResult(RESULT_OK,returnIntent);        
              finish();

          }

          else{
          PATH+="/Quran/";
          Main.Main_PATH=PATH;
          edittext_Dialog.setText(PATH);
          goodFileChoosen=true;
          }
      }

      break; 
    } 
  } 
}

Why is the FC happening?

EDIT1: dirSize() :

private long dirSize(File dir) {

    long result = 0;
    File[] fileList = dir.listFiles(); //line 387

    for(int i = 0; i < fileList.length; i++) {
        // Recursive call if it's a directory
        if(fileList[i].isDirectory()) {
            result += dirSize(fileList [i]);
        } else {
            // Sum the file size in bytes
            result += fileList[i].length();
        }
    }
    return result; // return the file size
}
  • 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-23T15:47:21+00:00Added an answer on May 23, 2026 at 3:47 pm

    The FC is happening at line 387 of DataDownload.java in your dirSize() method. Without seeing your full code, I don’t know why, but look at the objects referenced on that line and look for an object that has not been created / initialised.

    One possibility is that data.getStringExtra("FilePath"); is returning null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have 2 activities. 1-Messaging 2-fileBrowser from MESSAGING onButtonClick i call the FILEBROWSER activity.
In my main activity, I have the following code that calls my FileBrowser activity:
Is there a way to have an file browser for Flash that allows the
Have just started using Google Chrome , and noticed in parts of our site,
I have a C# .NET 3.5 app that I have incorporated the DragDrop event
I was working with background threads and orientation changes. i have gone through the
I have installed filebrowser for Django (not filebrowser3) and when I try to upload
I am running the development version of Django and it appears that the filebrowser
I need a file manager for Django Tinymce. I have tried Django filebrowser, but
I'm working on an asp.net file browser that recursively goes through folder and lists

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.