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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:59:00+00:00 2026-06-03T21:59:00+00:00

I have been able to retrieve values into my form.The values are inserted into

  • 0

I have been able to retrieve values into my form.The values are inserted into a table on save button click and are at the same time retrieved onto the same form too(on the same save click).But the problem now is that on each click the values are getting displayed in a continuous flow.I want to clear the screen(flush the values from form) after the previous click and display only the latest table state values.
Heres the code i am working on:

   public void fieldChanged(Field field, int context) //respond to button events
        {

            if (field == showInputButton) //if first button selected
            { 
                Dialog.alert(TextField1.getText()); //show text from first input field  

                try
                {    
                    //Open or create the database
                    Database db = DatabaseFactory.openOrCreate("database1.db");    

                    //Insert Data from db
                    Statement statement1 = db.createStatement("INSERT INTO DirectoryItems(category_id,name,phone,email) VALUES ('1','"+TextField1.getText()+"','"+TextField2.getText()+"','"+TextField3.getText()+"')");
                    statement1.prepare();
                    statement1.execute();       
                    statement1.close(); 
                  //Retrieve data
                    try
                    {
                            add(new RichTextField("Attempting to retrieve data from " + 
                                                                                        "database1.db on the SDCard."));


                            Statement st = db.createStatement("SELECT name FROM DirectoryItems");

                            st.prepare();


                            Cursor c = st.getCursor();

                            Row r;
                            int i = 0;

                            while(c.next()) 
                            {
                                        r = c.getRow();
                                        i++;
                                       add(new RichTextField(i + "Name = " + r.getString(0)));
                            }
                            if (i==0)
                            {
                                        add(new RichTextField("No data in the DirectoryItems table."));
                            }
                            st.close();
                            db.close();
                     }
                     catch( Exception e ) 
                    {         
                        System.out.println( e.getMessage() );
                        e.printStackTrace();
                    }

                  }

Does anyone know this.Please advise guys.

  • 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-03T21:59:01+00:00Added an answer on June 3, 2026 at 9:59 pm

    You can go ahead by disabling buttons so that you allow the user to fetch the values only once (i.e the latest values)

     ((ButtonField)showInputButton).setEnabled(false);
    

    Use that in your implementation of field change.Disabling buttons helps retain a good grip over the fetched values(as in your case).

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

Sidebar

Related Questions

I have been able to set up OBDC in Filemaker, and added table ,
Ran into an issue today that I have not been able to resolve. I
I have been able to implement the Bootstrap carousel complete with icons to represent
I have been able to execute a Stored Procedure in hibernate to map the
I have been able to enable and disable tabs in HTML and Javascript. I
I have been able to design my layout so that it has 2 columns
I have been doing a lot of reading but I have not been able
Till now I have been able to create an application where the Kinect sensor
Hi I have been able to extract a VARCHAR to a date using string_to_date
What I have been able to grasp from reading the source and documentation from

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.