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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:41:03+00:00 2026-05-24T15:41:03+00:00

Ok, thanks to below dude biggest issue is fixed. But whatever I print out,

  • 0

Ok, thanks to below dude biggest issue is fixed. But whatever I print out, none is printed and I cannot print out the message what is typed in class 2 (nimekysija) as well :(. I really need that it stores name and in future it will write down name every time! Thanks for your help!

Problem must be in 2nd class tho. When I update editor.putString(“nimi2”, nimiS); nimiS into “plapla”, then plapla actually shows up :/. So I have really no idea, what is problem!

(updated below classes too to the newest)


Class 1:

package viimane.voimalus;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.TextView;

public class MainStuff extends Activity {
    TextView tere;
    String nimi;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        tere = (TextView) findViewById(R.id.tvTere);
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        boolean nimiOlemas = preferences.getBoolean("nimionolemas", false);
        if (nimiOlemas == false){
             startActivity(new Intent("viimane.voimalus.NIMEKYSIJA"));
             finish();
        }
        if (nimiOlemas == true){
            nimi = preferences.getString("nimi2", "");
            System.out.print("töötab!");

            tere.setText("Tere " + nimi);
        }
        System.out.print("töötab2!");
    }
}

CLASS 2

package viimane.voimalus;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class nimekysija extends Activity {

    EditText nimi;
    SharedPreferences preferences;
    String nimiS;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nimekysija);
        preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        nimi = (EditText) findViewById(R.id.etNimekysija);
        nimiS = nimi.getText().toString();
        Button kysOk = (Button) findViewById(R.id.bNimekysija);
        kysOk.setOnClickListener(new View.OnClickListener() {      

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("nimi2", nimiS); // nime kirjutamine
                editor.putBoolean("nimionolemas", true); // nimi on kirjutatud!
                editor.commit();
                startActivity(new Intent("viimane.voimalus.MAINSTUFF"));
                finish();

            }
        });
    }

}
  • 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-24T15:41:05+00:00Added an answer on May 24, 2026 at 3:41 pm

    Ok I’m guessing you may be new to Java, forgive me if I’m incorrect. You never READ from nimiOlemas.

     boolean nimiOlemas = preferences.getBoolean("nimionolemas", false);
        nimiOlemas = false;
                    startActivity(new Intent("viimane.voimalus.NIMEKYSIJA"));
                    finish();
                   nimiOlemas = true;
    

    I think what you are trying to do is initialize nimiOlemas and then, if it is false, start an activity, call finish, then set nimiOlemas to true, but this is not what you are doing. Is this what you want?

    boolean nimiOlemas = preferences.getBoolean("nimionolemas", false);
    if (nimiOlemas == false)
    {
         startActivity(new Intent("viimane.voimalus.NIMEKYSIJA"));
         finish();
         nimiOlemas = true;
    }
    

    = is an assignment, == is a boolean comparison. You say in your question that you check the value of your boolean, but you never do, you only assign to it.

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

Sidebar

Related Questions

Thanks for the response, @ManselUK Fixed this part with finding values(below) But , when
thanks for taking the time to stop by my question. Below you will find
Thanks to AakashM, he led me in the right direction. For the question below,
Can someone explain the statement below to me with a working sample/example. thanks in
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
I can't get fancybox to open my links in iframe. My code below. Thanks!
The below code works fine on IE7 but not in Safari(5.0.5). If possible, I
I'm trying to figure out how to select the textarea in the code below
Running into some weird issue, can't quite figure out what's wrong. No errors popping
SOLUTION: Thanks to Patrick below, I have refactored the C# CodeProject version into a

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.