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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:08:48+00:00 2026-05-31T17:08:48+00:00

My question is how can i clear the editText field after i have saved

  • 0

My question is how can i clear the editText field after i have saved what i have written to it to the database? I currently can input text using the nameEditText field but when i click the InsertButton, it does not clear the for. I just want to clear the form not the value or string in the Database…This is the insert button i want to also use as a clear method:

  class InsertButtonListener implements OnClickListener, android.view.View.OnClickListener
    {
        public void onClick(View v) 
        {

            if("".equals(nameEditText.getText().toString())) 
            {
                Toast toast = Toast.makeText(Entername.this, "Sorry, you must input both the name and the address!", Toast.LENGTH_LONG); 
                toast.show();
            }
            else
            {
                long flag = 0;
                int id = 1;
                SQLiteDatabase db = dbHelper.getWritableDatabase();
                Cursor cursor = db.query("user_name", new String[]{"count(*) ID"}, null, null, null, null, null);
                while(cursor.moveToNext())
                {
                    int idFromDatabase = cursor.getInt(cursor.getColumnIndex("ID"));
                    if(idFromDatabase != 0)
                    {
                        id = 1 + idFromDatabase;
                    }
                }
                ContentValues values = new ContentValues();
                values.put("ID", id);
                values.put("name", nameEditText.getText().toString().trim());
                //values.put("address", addressEditText.getText().toString().trim());
                flag = db.insert("user_name", null, values);
                if(flag != -1)
                {
                    Toast toast = Toast.makeText(Entername.this, "You have successful inserted this record into database! ", Toast.LENGTH_LONG); 
                    toast.show();
                    db.close();
                    return;
                }
                else
                {
                    Toast toast = Toast.makeText(Entername.this, "An error occured when insert this record into database!", Toast.LENGTH_LONG); 
                    toast.show();
                    db.close();
                    return;
                }
            }
        }

        public void onClick(DialogInterface dialog, int which) 
        {
            // TODO Auto-generated method stub

        }
    }
  • 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-31T17:08:49+00:00Added an answer on May 31, 2026 at 5:08 pm

    You need to call:

    nameEditText.setText("");
    addressEditText.setText("");
    

    So, do the following change in your if condition when adding to database is successful:

    if(flag != -1)
    {
        Toast toast = Toast.makeText(Entername.this,
            "You have successful inserted this record into database! ",
            Toast.LENGTH_LONG); 
       toast.show();
       db.close();
    
       //clearing edittexts
       nameEditText.setText("");
       addressEditText.setText("");
    
       return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple (rather stupid) question, I hope someone can clear my
I have a EditText box so a user can input names and then click
After many investigations I can't find a clear answer to the following question: Can
The title pretty much asks the whole question - How can I clear ONLY
My question is not clear at title [i can not write it exactly] e.g
Question Can I build a image database/library that has an e-commerce style checkout system
this question can create a misunderstanding: I know I have to use CSS to
I didn't see a clear answer from the same question How can I figure
Hopefully this question is not to confusing, but I can help clear it up
I have a EditText box which is used to input names. Once the names

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.