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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:25:00+00:00 2026-06-14T13:25:00+00:00

db.insert function inserts only an auto incremented ID in the table and nothing else

  • 0

db.insert function inserts only an auto incremented ID in the table and nothing else though I get values from activity edit texts. Rest of the cells of table row remain empty

Here is my code:

public class SHelper extends SQLiteOpenHelper {

    static final String dbName = "School";
    static final String studentTable = "Student";
    static final String colName = "Name";
    static final String colPassword = "Password";
    public static final int dbVersion=1;

    public SHelper(Context context)
    {
        super(context, dbName, null, dbVersion);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE "+studentTable+"("+colID+" INTEGER PRIMARY KEY, "+colName+" TEXT,"+colPassword+" TEXT);");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + studentTable);
        onCreate(db);
    }

    public void add(StudentData studentdata) 
    {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put(colName, StudentData.getName()); 
        values.put(colPassword, StudentData.getPassword());
        db.insert(studentTable, null, values);
        db.close();
    }


}

public class StudentData {

    private static String name;
    private static String password;

    public StudentData() {
        super();
    }

    public StudentData(String name,String password) {
        super();

        StudentData.name = name;
        StudentData.password = password;
    }

    public static String getName() {
        return name;
    }

    public void setName(String name) {
        StudentData.name = name;
    }

        public static String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        StudentData.password = password;
    }
}

public class stoActivity extends Activity {

     SHelper db = new SHelper(this);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sto);

        final EditText fullname=(EditText)findViewById(R.id.fullName);
        final EditText password=(EditText)findViewById(R.id.password);

        final String fullname=fullname.getText().toString();
        final String password=password.getText().toString();

        Button registerbutton = (Button) findViewById(R.id.registerButton);      
        registerbutton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v){

            db.add(new StudentData(fullname,password));  

           Intent it=new Intent(stoActivity.this,otherActivity.class);
           stoActivity.this.startActivity(it);   
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_register, menu);
        return true;
    }
}
  • 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-14T13:25:01+00:00Added an answer on June 14, 2026 at 1:25 pm

    There’s your issue:

    public void add(*StudentData studentdata) 
        {
            ...    
            values.put(colName, *StudentData.getName()); 
            values.put(colPassword, *StudentData.getPassword());
            ...
        }
    

    Can you see it? Your statement is referring to the wrong part of the signature. you need to change the StudentData in the body of your method to lower case studentdata to match what is being passed to the method as a parameter. This illegal behavior went by compiled because you have the static modifier in places where i’m not sure is necessary, ex. the getName() and getPassword() methods.

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

Sidebar

Related Questions

I am Looking for a Function that insert Any form values to mysql ,
I have some PHP code that inserts a date into a table: INSERT INTO
I am wondering if wordpress' insert function also adds slashes to data. If it
I have a PHP function which inserts multiple records into MySQL: function commit_purchase($asset_type_ID, $org_ID,
I have my controller, my function to insert into the database, and the form.
I'm using folding-mode in emacs and was trying to make a function to insert
here is myproblem, i want to make a php function to insert some random
I'm using the .load() function in jquery to insert the results of a php
I have function: char *zap(char *ar) { char pie[100] = INSERT INTO test (nazwa,
I'm adding a field to my table called room_num. Basically upon insert I'd like

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.