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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:36:14+00:00 2026-05-20T17:36:14+00:00

Ok so i have 5 arrays all with 5 elements in them in my

  • 0

Ok so i have 5 arrays all with 5 elements in them in my strings.xml file like so:

<string-array name="monday">
        <item>monday</item>
        <item>tuesday</item>
        <item>wednesday</item>
        <item>thursday</item>
        <item>friday</item>
    </string-array>

now i have a switch statement in my code that deppending on the button that they click will set one of these 5 arrays to my main array. however i have tried many differant ways but i still get null pointer exception on this line:

Days.masterarray = getResources().getStringArray(R.array.monday);

also trued this but got the same result:

Days.setMasterarray(getResources().getStringArray(R.array.monday));

master array:

public static String[] masterarray = new String[] { "monday", "tuesday",
            "wednesday", "thursday", "friday" };

i have given it default values to begin with. now when i run the switch statement i get this:

03-19 13:43:23.555: WARN/System.err(1379): java.lang.NullPointerException
03-19 13:43:23.586: WARN/System.err(1379):     at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
03-19 13:43:23.586: WARN/System.err(1379):     at schoolBook.Icestone.Days.setArray(Days.java:77)
03-19 13:43:23.595: WARN/System.err(1379):     at schoolBook.Icestone.SampleActivity.onCreate(SampleActivity.java:27)
03-19 13:43:23.605: WARN/System.err(1379):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-19 13:43:23.626: WARN/System.err(1379):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
03-19 13:43:23.626: WARN/System.err(1379):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1577)
03-19 13:43:23.635: WARN/System.err(1379):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:130)
03-19 13:43:23.644: WARN/System.err(1379):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:342)
03-19 13:43:23.655: WARN/System.err(1379):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:680)
03-19 13:43:23.676: WARN/System.err(1379):     at android.widget.TabHost.setCurrentTab(TabHost.java:349)
03-19 13:43:23.676: WARN/System.err(1379):     at android.widget.TabHost.addTab(TabHost.java:239)
03-19 13:43:23.695: WARN/System.err(1379):     at schoolBook.Icestone.Days.onCreate(Days.java:32)
03-19 13:43:23.695: WARN/System.err(1379):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-19 13:43:23.695: WARN/System.err(1379):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
03-19 13:43:23.716: WARN/System.err(1379):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
03-19 13:43:23.716: WARN/System.err(1379):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-19 13:43:23.716: WARN/System.err(1379):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
03-19 13:43:23.735: WARN/System.err(1379):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 13:43:23.735: WARN/System.err(1379):     at android.os.Looper.loop(Looper.java:126)
03-19 13:43:23.744: WARN/System.err(1379):     at android.app.ActivityThread.main(ActivityThread.java:3997)
03-19 13:43:23.754: WARN/System.err(1379):     at java.lang.reflect.Method.invokeNative(Native Method)
03-19 13:43:23.754: WARN/System.err(1379):     at java.lang.reflect.Method.invoke(Method.java:491)
03-19 13:43:23.754: WARN/System.err(1379):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-19 13:43:23.775: WARN/System.err(1379):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-19 13:43:23.775: WARN/System.err(1379):     at dalvik.system.NativeStart.main(Native Method)

any light on how to fix this would be much appreciated

  • 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-20T17:36:15+00:00Added an answer on May 20, 2026 at 5:36 pm

    I think getResources might be null. Try either

    • placing a breakpoint at that line and debug to see if it is null (if it is not null, then find what is null)
    • using the context. ie.
      mContext.getResources().getStringArray(R.array.monday));
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You have: val array = new Array[Array[Cell]](height, width) How do you initialize all elements
I have three arrays, all the same size: xout % cell array xin %
The goal is to have an array where all strings are of length n.
I have an array of array like below with all numeric values. I want
I have an array of strings: @array I want to concatenate all strings beginning
I have an object array, I know that the elements are type String, say
I will have four word list arrays. $array1 = array('red','blue','green');//it can have more elements
I have three arrays each having SimpleXML Objects in them. They are structured like
If I have two different arrays and all I can do is check whether
I have an array of values all well within the range 0 - 63,

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.