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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:48:18+00:00 2026-06-04T13:48:18+00:00

I am making an application to Store textfield values to database.After entering values when

  • 0

I am making an application to Store textfield values to database.After entering values when I press the button to submit it, it just hanged and give no response.

my onCreate code is given below:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final DBAdapter db = new DBAdapter(this);

      //---add 2 titles---
        db.open();
        final long d_id ;  
        final EditText input1 = (EditText) findViewById(R.id.isbn);
        final String   isbn   = input1.getText().toString();

        final EditText input2 = (EditText) findViewById(R.id.titleText);
        final String   tText   = input2.getText().toString();

        final EditText input3 = (EditText) findViewById(R.id.publisherText);
        final String   pText   = input3.getText().toString();

        this.btn = (Button)this.findViewById(R.id.button1);
        this.btn.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v) {
                db.insertTitle(isbn, tText, pText);

            }
        });

         db.close();
    }

}

isbn,titleText and publisherText are my id for Textfield.
insertTitle is function to insert the values.

Whats wrong with my code?

thanks.

  • 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-04T13:48:20+00:00Added an answer on June 4, 2026 at 1:48 pm

    You are reading the values of your text fields as the app is being created, not when the button is pushed. You will always enter the initial values of your EditTexts with your current code. Try this:

    db.insertTitle(input1.getText().toString(), input2.getText().toString(), input3.getText().toString());
    

    You will have to move where you close your database, otherwise you will get an error for attempting to access a closed database. Try putting it in onPause() or onDestroy().

    If this isn’t the solution please post your logcat errors so we don’t have to guess what is happening.

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

Sidebar

Related Questions

I'm making an application that contains button's and those buttons control an embedded browser.
I am working on making an application that will store information, and for user
A website that I'm working on is making extensive use of the HttpContext.Current.Application store
I'm making and tablet application to a store, and the application needs to have
I'm currently developing an application that needs to store data in it's on database,
I am making a small iPhone application in which I have implemented the database
I am making an application in which I have to store data from remote
I'm making an application which uses OpenGL and currently store an array of objects
I have completed the MVC Music Store application, and now am making my own
hi all: making a sample application in which we can store data on File

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.