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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:28:58+00:00 2026-05-20T07:28:58+00:00

I’m creating sign_up and sign_in page and data that type into editview will be

  • 0

I’m creating sign_up and sign_in page and data that type into editview will be store in database.
So for database I create one class named DBAdapter.java and my anotherfile is signup.java and login.java.
So I want to do that when I click on submit button data will be store in database.
But issue is that I cannot use DBAdapter.java’s instance db into onclick event of submit button and same issue with login button in login.java file.

thanks in advance…

public class DBAdapter 
{
    public static final String KEY_ROWID = "_id";
    public static final String KEY_FIRSTNAME = "FirstName";
    public static final String KEY_LASTNAME = "LastName";
    public static final String KEY_USERNAME = "UserName";
    public static final String KEY_PASSWORD = "Password";    
    private static final String TAG = "DBAdapter";

    private static final String DATABASE_NAME = "master";
    private static final String DATABASE_TABLE = "register";
    private static final int DATABASE_VERSION = 1;

    private static final String DATABASE_CREATE =
        "create table titles (_id integer primary key autoincrement, "
        + "FirstName text not null, LastName text not null, " 
        + "UserName text not null, Password text not null);";

    private final Context context; 

    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public DBAdapter(Context ctx) 
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    private static class DatabaseHelper extends SQLiteOpenHelper 
    {
        DatabaseHelper(Context context) 
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) 
        {
            db.execSQL(DATABASE_CREATE);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, 
        int newVersion) 
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion 
                    + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }

and signup.java

public class SignUp extends Activity {

    private EditText firstname;
    private EditText lastname;
    private EditText username;
    private EditText password;

    public String first_name;
    public String last_name;
    public String user_name;
    public String pass_word;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        DBAdapter db = new DBAdapter(this);

        firstname = (EditText) findViewById(R.id.ev_fname);
        lastname = (EditText) findViewById(R.id.ev_lname);
        username = (EditText) findViewById(R.id.ev_uname);
        password = (EditText) findViewById(R.id.ev_password);

        final Button button = (Button) findViewById(R.id.btn_submit);
        button.setOnClickListener(new View.OnClickListener() {           
            public void onClick(View v) {              
                first_name = firstname.getText().toString();
                last_name = lastname.getText().toString();
                user_name = username.getText().toString();
                pass_word = password.getText().toString();



                Intent goToNextActivity = new Intent(getApplicationContext(), link.class);
                startActivity(goToNextActivity);


            }
        });
  • 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-20T07:28:59+00:00Added an answer on May 20, 2026 at 7:28 am

    It’s more of a hack, I think, but what stops you from having this?

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

    I’d like to find a more elegant solution myself, as there are multiple needs for this in my apps too.

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

Sidebar

Related Questions

No related questions found

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.