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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:17:23+00:00 2026-06-05T10:17:23+00:00

I have an int/string(s) that is passed from one fragment to another. For each

  • 0

I have an int/string(s) that is passed from one fragment to another. For each way I code it, I get a NPE at line 67 (see where 67 is below). I dont know If I am going about it in the correct way so please look thru my methods and include some code in your answer.

Thnx.

What passes the arguments:

. . .
        int rawRes = R.raw.regulatory_list;//<--THIS IS THE RES I NEED TO PASS
        args.putInt("KEY_RAW_RES", rawRes);

        boolean isRawRes = true;
    args.putBoolean("KEY_IS_RAW_RES", isRawRes);

        ListViewFragment lvf = new ListViewFragment();
        lcFT.replace(R.id.discriptionListContainer, lvf).commit();
        lvf.setArguments(args);
. . .

ListViewFragment’s onActivityCreated:

. . .
private static final String KEY_URL = "KEY_URL";
    private static final String KEY_IS_RAW_RES = "KEY_IS_RAW_RES";
    private static final String KEY_RAW_RES = "KEY_RAW_RES";
. . .

@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

// Get the string to query from last Fragment and pass it to this
        // Fragment
        Bundle args = this.getArguments();

        String url = args.getString(KEY_URL);
        boolean rawRes = args.getBoolean(KEY_IS_RAW_RES);

        int fileName = (Integer) null;//<--THIS IS LINE 67!!
        fileName = args.getInt(KEY_RAW_RES);

        this.runJsonFile(url, jsonSrc, fileName);
}

private void runJsonFile(String url, boolean rawRes, int fileName) {

    if (rawRes == true) {
        getFromRawRes(fileName);
    } else {
        getFromURL(url);
    }
}

    private void getFromRawRes(int fileName) {
//      InputStream file = getResources().openRawResource(R.raw.regulatory_list);
        InputStream file = getResources().openRawResource(fileName);
        JSONParser jParser = new JSONParser();
        JSONArray json = jParser.getJSONFromFile(file);
        callback(json);
    }

EDIT:

I change lines 67 – 68 as per Raghav Sood answer to:

//      int fileName = (Integer) null;
        int fileName = args.getInt(KEY_RAW_RES);

This got the class past the NPE – Thnx!!

  • 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-06-05T10:17:25+00:00Added an answer on June 5, 2026 at 10:17 am

    You’re casting a null value to an integer variable. There is no conceivable scenario in which this will not result in a NullPointerException, since you are using null in the first place. In Java, and several other languages, primitive data types like integer, double, char etc cannot be null.

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

Sidebar

Related Questions

I have a Func in my code that's declared like this: Func<string, int, bool>
I have a Supplier Entitiy that contains ID - int Status - string Name
I have a Supplier Entitiy that contains ID - int Status - string Name
That is, I have a method such as the following: public static int CreateTaskGroup(string
If I have a function that produces a result int and a result string
I have tried to use the following snippet of code: int main() { string
I have about thirty strings that get passed to my stored procedure which act
I have this methods getParam public int getParam(String paramName){ if(paramName.equals(Balls and net)){ expressionParam=1; }
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
I have an unordered map: class O(val a: Int) Map[String, List[O]] which I'd like

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.