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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:23:54+00:00 2026-06-09T00:23:54+00:00

Here is the code which i use to load the spinner in the .MainActivity.java

  • 0

Here is the code which i use to load the spinner in the .MainActivity.java

    public void spin() {
    {  
        try{  
            SQL db = new SQL(getBaseContext());  
            db.open();  
            List<String> cursor = db.selectAll();
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,  
                android.R.layout.simple_spinner_item, cursor);
                s.setAdapter(adapter);  
        }  
        catch(Exception e)  
        {  
        Log.v("Error","e.tostring()");  
        }
    }  

Here is the code in the SQL.java to get the items from the database.

    public List<String> selectAll() {
    List<String> list = new ArrayList<String>();
    Cursor cursor = this.mydb.query(DATABASE_TABLE, new String[] {KEY_NAME
    }, null, null, null, null, null);
    if (cursor.moveToFirst()) {
        do {
            list.add(cursor.getString(0));
        } while (cursor.moveToNext());
    }
    if (cursor !=null && !cursor.isClosed()) {
        cursor.close();
    }
    return list;
}

this is how i add records from another activity .Addnew.java

case R.id.bsave:
            boolean work=true;
            try{
            String rno1 = rno.getText().toString();
            String name1 = name.getText().toString();
            String reg1 = reg.getText().toString();
            String mob1 = mob.getText().toString();

            SQL entry = new SQL(Addnew.this);
            entry.open();
            entry.createEntry(rno1,name1,reg1,mob1);
            entry.close();
            }
            catch(Exception e){
                work=false;
                String error = e.toString();
                Dialog d = new Dialog(this);
                d.setTitle("Naah");
                TextView tv = new TextView(this);
                tv.setText(error);
                d.setContentView(tv);
                d.show();
            }finally{
                if(work){
                    Dialog d = new Dialog(this);
                    d.setTitle("Yeah");
                    TextView tv = new TextView(this);
                    tv.setText("Success");
                    d.setContentView(tv);
                    d.show();
                }
            }
            break;

The problem is when I insert a new record in the database it doesn’t show up in the spinner immediately, rather it shows it only after restarting the application. can someone help me fix this?

  • 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-09T00:23:56+00:00Added an answer on June 9, 2026 at 12:23 am

    Try refreshing your activity by any one of the method

    startActivity(getIntent);
    

    or

    Intent addservice1 = new Intent(YourActivity.this,YourActivity.class);
                    startActivity(addservice1);
    

    It will solve your issue.

    Hope it helps

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

Sidebar

Related Questions

Here's sample model classes, which being use with Entity Framework Code First: public class
I have this block of code here which I use to load an image
Here is the code which test in IE8: var stack = []; function test()
Here is jquery code which hides my table cells with the ID of .style2:
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
Here is my code which is doing the conversion from hex to decimal. The
I have some code here which works perfectly in firefox but not in chrome
I have this piece of Open MP code here which performs an integeration of
I need help with a weird runtime error. Here's the code which gives it:
i have this quick issue please. I have this code here which permits me

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.