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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:24:32+00:00 2026-05-31T13:24:32+00:00

Do i have to declare something in android manifest? I’m trying to have text

  • 0

Do i have to declare something in android manifest? I’m trying to have text input that is in notes.java save even when the activity is destroyed. So i used SharedPreferences. “editText1” is the text input in notes.xml When i run the app it force closes Here’s notes.java:

public class notes extends Activity {
    public static final String PREFS_NAME = "MyPrefsFile";
    private EditText mEditText;

    @Override
    protected void onCreate(Bundle state){
       super.onCreate(state);


       // Restore preferences
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
       String savedText = settings.getString("text", "");
       mEditText = (EditText) findViewById(R.id.editText1);
       mEditText.setText(savedText);
    }

    @Override
    protected void onStop(){
       super.onStop();

      // We need an Editor object to make preference changes.
      // All objects are from android.context.Context
      SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putString("text", mEditText.getText().toString());

      // Commit the edits!
      editor.commit();
    }
}

Here’s the Logcat for when it force closes:

03-17 16:54:42.302: E/AndroidRuntime(14558): FATAL EXCEPTION: main
03-17 16:54:42.302: E/AndroidRuntime(14558):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{izzy.n/izzy.n.notes}: java.lang.NullPointerException
03-17 16:54:42.302: E/AndroidRuntime(14558): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
03-17 16:54:42.302: E/AndroidRuntime(14558): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
03-17 16:54:42.302: E/AndroidRuntime(14558): at
android.app.ActivityThread.access$1500(ActivityThread.java:132) 03-17
16:54:42.302: E/AndroidRuntime(14558): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
03-17 16:54:42.302: E/AndroidRuntime(14558): at
android.os.Handler.dispatchMessage(Handler.java:99) 03-17
16:54:42.302: E/AndroidRuntime(14558): at
android.os.Looper.loop(Looper.java:150)

  • 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-31T13:24:33+00:00Added an answer on May 31, 2026 at 1:24 pm

    You need to call setContentView before findViewById:

    setContentView(R.layout.main);
    mEditText = (EditText) findViewById(R.id.editText1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have objects with many variables that I declare and explain in the comments.
I have a query that sums and aggregates alot of data something like this:
So now I have my BroastcastReceiver declared in the manifest file... <receiver android:name=.MyReceiver> <intent-filter>
In my Android activity, I create a custom view that extends SurfaceView (using MonoDroid
When you declare something as input or output, how do you know if you
I have an Android application in which I'm trying to parse a small sized
If I have a method that does something with multiple Subsonic ActiveRecords and doesn
I have some documentation that doesn't have any intuitive examples for me http://developer.android.com/reference/android/nfc/tech/NfcV.html http://developer.android.com/reference/android/nfc/Tag.html
I have an android application that has a button which I want to have
i have two table: declare @t1 table (id int) declare @t2 table (id int)

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.