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

  • Home
  • SEARCH
  • 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 8517135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:37:05+00:00 2026-06-11T05:37:05+00:00

EDIT : The problem was not the SharedPreference! It was my wav-data. Android supports

  • 0

EDIT: The problem was not the SharedPreference! It was my wav-data. Android supports only 8- and 16-bit linear PCM wave formats. I used a 32-bit float.

today I recieved a error report via BugSense. A User had a NullPointException because of the sharedPreferences. I recieved this error for the first time.

Here is my relevant code:

The Settings where I set the sharedPreference:

private void dialogSettings() {
    final Dialog dialog = new Dialog(this, R.style.dialog_style);
    dialog.setContentView(R.layout.dialog_settings);
    final CheckBox sound = (CheckBox) dialog.findViewById(R.id.checkBoxSound);
    final CheckBox vibration = (CheckBox) dialog.findViewById(R.id.checkBoxVibration);
    final SharedPreferences pref = getSharedPreferences("SETTINGS", 0);
    sound.setChecked(pref.getBoolean("SOUND", true));
    vibration.setChecked(pref.getBoolean("VIBRATION", true));
    Button buttonSave = (Button) dialog.findViewById(R.id.buttonSave);
    buttonSave.setOnClickListener(new OnClickListener() {       
        public void onClick(View v) {
            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean("SOUND", sound.isChecked());
            editor.putBoolean("VIBRATION", vibration.isChecked());
            editor.commit();
            dialog.dismiss();
        }
    });
    dialog.show();
}

The use of “SOUND” (other Activity):

private boolean SOUND;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.game_normal_layout);
    SharedPreferences pref = getSharedPreferences("SETTINGS", 0);
    SOUND = pref.getBoolean("SOUND", true); 
    ....
}

private void evaluateAnswer() {
    if(correct) {
        if(SOUND) {  // LINE 259
            ding.seekTo(0);
            ding.start();
        }
    ...
}

And here is the Exception:

java.lang.NullPointerException
at mindmApp.quiz.GameNormalActivity.evaluateAnswer(GameNormalActivity.java:259)

So, the variable SOUND is null. But why? Because of SOUND = pref.getBoolean(“SOUND”, true) it must be initialised, or not?

Thanks for all help,

best regards!

  • 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-11T05:37:06+00:00Added an answer on June 11, 2026 at 5:37 am

    SOUND can’t be null (booleans are a primitive type, which can be uninitialized, but not null). The more likely answer is that “ding” is null.

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

Sidebar

Related Questions

[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
EDIT: Problem solved. It was my reading that was incorrect, not the SQL :p
EDIT: the problem was not on hiding them (as I first thought), It was
EDIT: Problem was not related to the binding but to a simple JavaScript mistake.
[EDIT: Problem solved. Please see my answer below.] In my app I call the
Ok, I'll put the code first hopefully to make it clearer. ***Edit: Problem is
Edit: This problem was down to me passing the wrong view to the Touch
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Edit 1: Uninstalled & Reinstalled Edit 2: Same problem. Seriously? Yes. I am having
Most of you probably know the following problem: You edit an HTML, view the

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.