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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:01:27+00:00 2026-05-26T18:01:27+00:00

Good day, Any idea why i could be getting a NullPointerException in the following

  • 0

Good day, Any idea why i could be getting a NullPointerException in the following code. I am trying to retrieve elements from a string-array in XML and test against a given value but i keep getting a NullpointerException on the first line of the code below.

 String [] position = context.getResources().getStringArray(R.array.google_weather_conditions); // NullpointerException here        
            for(String check: position){
               String test_condition = check;
               if(this.condition.equals(test_condition)){
                  weather_conditions = test_condition;
               }
                    }

here is the strings.xml file:

<?xml version="1.0" encoding="utf-8"?>
    <resources>
     <string name="Clear">Clear</string>
     <string name="Sunny">Sunny</string>
     <string name="Mostly_Sunny">Mostly Sunny</string>
     <string name="Partly_Sunny">Partly Sunny</string>
     <string name="Cloudy">Cloudy</string>
    <string name="Mostly_Cloudy">Mostly Cloudy</string>
    <string name="Partly_Cloudy">Partly Cloudy</string>
    <string name="Rain">Rain</string>

     <string-array name="google_weather_conditions">
            <item>@string/Clear</item>
            <item>@string/Sunny</item>
            <item>@string/Mostly_Sunny</item>
            <item>@string/Partly_Sunny</item>
            <item>@string/Cloudy</item>
            <item>@string/Mostly_Cloudy</item>
            <item>@string/Partly_Cloudy</item>
            <item>@string/Rain</item>
        </string-array>


    </resources>
  • 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-26T18:01:28+00:00Added an answer on May 26, 2026 at 6:01 pm

    Most likely context is null at the point of the NPE.

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

Sidebar

Related Questions

Good day, I'm trying to convert my site from ANSI-encoded PHP files to UTF-8.
Good Day. I'm looking for switch replacement in jQuery. Basically, I have no idea
Good day, Is there a Regex that I could use to prepend a 0
G'day, OK, I have now rewritten this question totally: I am trying to import
I've got an idea for a new web app which will involve the following:
Good day, I have a local csv file with values that change daily called
Good Day! How to add a textbox pop-up menu when I right click on
good day, i am having a bit of a problem here. i am using
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day to all. I need to loop a flv file in flash if

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.