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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:43:00+00:00 2026-06-13T07:43:00+00:00

I have an Android application that simply saves data and displays them in a

  • 0

I have an Android application that simply saves data and displays them in a list view, very similar to the Notepad tutorial. Unfortunately my Add activity seems to have stopped working somewhere along the line. When I attempt to add data and press Confirm, it reloads the Activity (the screen flickers slightly) and any data I have entered into the fields is cleared . I have confirmed that it is not reaching onSaveInstanceState(). I was under the impression that this method was called automatically upon finish(), and like I mentioned it was working at one time. Maybe someone can spot where I have introduced an error into my code? I’ll paste what I believe are the relevant parts:

 confirmButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {

            //Verify that fields are filled out
            String description = mDescriptionText.getText().toString();
            String amount = mAmountText.getText().toString();
            if(description.length() == 0 || amount.length() == 0) {
                if(description.length() == 0) {
                    Context context = getApplicationContext();
                    CharSequence text = "A description is required";
                    int duration = Toast.LENGTH_SHORT;
                    Toast toast = Toast.makeText(context, text, duration);
                    toast.show();
                }
                else {
                    Context context = getApplicationContext();
                    CharSequence text = "An amount is required";
                    int duration = Toast.LENGTH_SHORT;
                    Toast toast = Toast.makeText(context, text, duration);
                    toast.show();
                }

            }
            else {
                /* Call this to set the result that your activity will return to its caller */
                setResult(RESULT_OK);
                /* Call this when your activity is done and should be closed. The ActivityResult is propagated back to 
                whoever launched you via onActivityResult() */ 


                finish();
            }
        }


    @Override
protected void onSaveInstanceState(Bundle outState) {
    Log.i("expEdit","onSaveInstance State Reached");
    super.onSaveInstanceState(outState);
    saveState();
    outState.putSerializable(EZBudgetDbAdapter.KEY_ROWID, mRowId);
}


 private void saveState() {
    Log.i("expEdit","saveState Reached");
    String description = mDescriptionText.getText().toString();
    String amount = mAmountText.getText().toString();
    Double dAmount = 0.0;
    if(amount != "") {
        dAmount = Double.valueOf(amount).doubleValue();
    }

    if (mRowId == null) {
        long id = mExpDbHelper.createExpenditure(description, dAmount);
        if (id > 0) {
            mRowId = id;
        }

        if (mSaveDesc.isChecked()) {
            // Save the description to the CommonDesc table
            mCommDbHelper = new CommonDescDbAdapter(this);
            mCommDbHelper.open();
            mCommDbHelper.createCommonDesc(description);

        }

    } else {

        mExpDbHelper.updateExpenditure(mRowId, description, dAmount);

        if (mSaveDesc.isChecked()) {
            // Save the description to the CommonDesc table
            mCommDbHelper = new CommonDescDbAdapter(this);
            mCommDbHelper.open();
            mCommDbHelper.createCommonDesc(description);

        }


    }
}
  • 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-13T07:43:00+00:00Added an answer on June 13, 2026 at 7:43 am

    onSaveInstanceState() is not called after finish(). See following onSaveInstanceState

    and your code is not clean. Never duplicate code for nothing. You should use

        Context context = getApplicationContext();
        CharSequence text;
        int duration = Toast.LENGTH_SHORT;
    
        if(description.length() == 0) {                    
            text = "A description is required";                 
        } else {                    
            text = "An amount is required";                    
        }
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application that displays a toast every hour and then every
I have a simple Android application that uses a JAR I have built. When
I'm developing a simple Android application that would have an action bar on the
I have an android application that launches a child Activity under certain situations. Both
I have an Android application that connects to Facebook to request authorization of an
I have an Android application that uses the Android database to create tables and
I have an android application that requres a login based on users in a
I have an android application that has 3 activites. For the 1st and 2nd
I have created an android application that calls (using kSOAP library) a SOAP based
I have a Web Service and an Android application that uses this web service.

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.