Android: Unable to insert data into SQLite using DbHelper and Contract class

后端 未结 1 1215
不知归路
不知归路 2021-01-27 11:47
public class Main2Activity extends AppCompatActivity {
    private EditText editText1, editText2, editText3, editText4;
    private Button button;

    @Override
    pro         


        
相关标签:
1条回答
  • 2021-01-27 12:09

    Replace your CREATE_TABLE query with:

    String CREATE_TABLE = "CREATE TABLE " + Entry.TABLE_NAME + " ("
                    + Entry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                    + Entry.C_UNAME + " TEXT, "
                    + Entry.C_PASS + " TEXT, "
                    + Entry.C_CPASS + " TEXT, "
                    + Entry.C_PNO + " TEXT" + ")";
    

    You can't have a TEXT type have an AUTOINCREMENT property as you currently have it on your _ID field. You need to change it to be an INTEGER so it can be used as PRIMARY KEY and then have it AUTOINCREMENT

    0 讨论(0)
提交回复
热议问题