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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:47:26+00:00 2026-06-15T20:47:26+00:00

I am creating an app that accept user info for registration but I was

  • 0

I am creating an app that accept user info for registration but I was getting an error saying ‘no such table: UserAccount’ below are my codes:

My DBHelper

public class DBAdapter 
{

    public static final String KEY_ROWID = "_id";
    public static final String KEY_TITLE = "title";
    public static final String KEY_FULLNAME = "fullname";
    public static final String KEY_EMAIL = "email";
    public static final String KEY_PASS = "password";   
    private static final String TAG = "DBAdapter";

    private static final String DATABASE_NAME = "pioneer.db";
    private static final int DATABASE_VERSION = 1;
    public static final String DATABASE_TABLE_NAME = "UserAccount";

    private static final String DATABASE_CREATE =
        "create table IF NOT EXISTS users (_id integer primary key autoincrement, "
        + "title text, fullname text, email text, password text);";

    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 users");
            onCreate(db);
        }
    }    

    //---opens the database---
    public DBAdapter opendb() throws SQLException 
    {
        db = DBHelper.getWritableDatabase();
        return this;
    }

    //---closes the database---    
    public void close() 
    {
        DBHelper.close();
    }

    //---insert a title into the database---
    public long insertUser(String title, String fullname,String email, String Password) 
    {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_TITLE, title);
        initialValues.put(KEY_FULLNAME, fullname);
        initialValues.put(KEY_EMAIL, email);
        initialValues.put(KEY_PASS, Password);
        return db.insert(DATABASE_TABLE_NAME, null, initialValues);
    }

    //---deletes a particular title---
    public boolean deleteTitle(long rowId) 
    {
        return db.delete(DATABASE_TABLE_NAME, KEY_ROWID + 
          "=" + rowId, null) > 0;
    }

    //---retrieves all the titles---
    public Cursor getAllUsers() 
    {
        return db.query(DATABASE_TABLE_NAME, new String[] {
          KEY_ROWID, 
          KEY_TITLE,
          KEY_FULLNAME,
          KEY_EMAIL,
          KEY_PASS,
          }, 
        null, 
        null, 
        null, 
        null, 
        null);
    }

    //---retrieves a particular user---
    public Cursor getUser(long rowId) throws SQLException 
    {
        Cursor mCursor =
                db.query(DATABASE_TABLE_NAME, new String[] {
                          KEY_ROWID, 
                          KEY_TITLE,
                          KEY_FULLNAME,
                          KEY_EMAIL,
                          KEY_PASS,
                          }, 
                  KEY_ROWID + "=" + rowId, 
                  null,
                  null, 
                  null, 
                  null, 
                  null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    //---updates a title---
    public boolean updateTitle(long rowId, String title, String fullname,String email, String Password)
    {
        ContentValues args = new ContentValues();
        args.put(KEY_TITLE, title);
        args.put(KEY_FULLNAME, fullname);
        args.put(KEY_EMAIL, email);
        args.put(KEY_PASS, Password);


        return db.update(DATABASE_TABLE_NAME, args, 
                         KEY_ROWID + "=" + rowId, null) > 0;
    }
}

And this is where i use it

public class RegisterActivity extends Activity {
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        final EditText full_Name = (EditText)findViewById(R.id.reg_fullname);
        final EditText mMail = (EditText)findViewById(R.id.reg_email);
        final EditText mPass = (EditText)findViewById(R.id.reg_password);
        final TextView loginScreen = (TextView) findViewById(R.id.link_to_login);
        btn = (Button)findViewById(R.id.btnRegister);

        final DBAdapter db = new DBAdapter(this);
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (db !=null){
                db.opendb();
                long uid =db.insertUser("Mr", full_Name.getText().toString(), mMail.getText().toString(), mPass.getText().toString());

                Cursor c = db.getUser(uid);
                if (c !=null){
                    ShowMessage(c.getString(2));
                }
                }
                db.close();


            }

        });
        }

        private void ShowMessage(String message){
            Toast.makeText(this, message, Toast.LENGTH_LONG).show();
        }

        // Listening to Login Screen link
     /*   loginScreen.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                                // Closing registration screen
                // Switching to Login Screen/closing register screen
                finish();
            }
        });*/

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_register, menu);
        return true;
    }

}

Any help will be appreciated.

  • 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-15T20:47:28+00:00Added an answer on June 15, 2026 at 8:47 pm

    You are creating a table with a name (users) different from the one used in the query statements (UserAccount)..

    public static final String DATABASE_TABLE_NAME = "UserAccount";
    
    private static final String DATABASE_CREATE =
        "create table IF NOT EXISTS users (_id integer primary key autoincrement, "
        + "title text, fullname text, email text, password text);";
    

    it should be:

    private static final String DATABASE_CREATE =
        "create table IF NOT EXISTS "+ DATABASE_TABLE_NAME+" (_id integer primary key autoincrement, "
        + "title text, fullname text, email text, password text);";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an app that alerts user if he has been stationary for
I am creating an app that allows the user to do some hand-drawing. The
I'm creating a iOS app that requires the user to log in at startup,
I am creating an app that will point a simple arrow in the direction
I am creating an app that is a ticket sales system. On the checkout
I am creating an app that allows users to create and apply for jobs.
I'm creating an app that should list the date and time when a button
I'm creating an app that uses ActionBarSherlock. The app consists of three tabs, and
I am creating an app that requires some settings to be set first before
I'm creating and app that will rely on a database, and I have all

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.