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 try to start new Activity from another. But it always crashed.
Good Day. I'm looking for switch replacement in jQuery. Basically, I have no idea
Could not convert or access JSON object from PHP json_encode <?php $f_array = array();
Good day everyone, I have an HTACCESS file that contains the following: Options +FollowSymlinks
I'm trying to grab a random item from a string list and save that
Good day. I need to teach Windows CryptoAPI to encrypt the message with private
Good Day, Can someone confirm what was said at the bottom of this post
Good day, I have a class that implements the LoaderCallbacks, and hence have the
Good day, just a quick question: I would like to bind a table to

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.