SQLite NOT NULL约束失败 - 如何解决?

问题描述 投票:-1回答:1

我在将数据从文本视图插入SQL表时遇到问题。这是我写的代码:

代码示例:

if (competencies_title.equals( "Genetic Competencies")) {
                    databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
                    Bundle bundle = new Bundle();
                    loginName = login_name.getText().toString();
                    recommendedmodule = recommendedModules.getText().toString();
                    studentcomments = comments.getText().toString();
                    bundle.putString("name", loginName);
                    Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
                    bundle.putString("description", "You have answered all questions for Genetic Competencies");
                    intent.putExtra("answer1", answerName1);
                    intent.putExtra("answer2", answerName2);
                    intent.putExtra("answer3", answerName3);
                    intent.putExtra("answer4", answerName4);
                    intent.putExtra("recommendedModules", recommendedmodule);
                    intent.putExtra("comments", studentcomments);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }
                if (competencies_title.equals("Technical Competencies")) {
                    databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
                    Bundle bundle = new Bundle();
                    loginName = login_name.getText().toString();
                    recommendedmodule = recommendedModules.getText().toString();
                    studentcomments = comments.getText().toString();
                    bundle.putString("name", loginName);
                    Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
                    bundle.putString("description", "You have answered all questions for Technical Competencies");
                    intent.putExtra("answer1", answerName1);
                    intent.putExtra("answer2", answerName2);
                    intent.putExtra("answer3", answerName3);
                    intent.putExtra("answer4", answerName4);
                    intent.putExtra("recommendedModules", recommendedmodule);
                    intent.putExtra("comments", studentcomments);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }
android android-sqlite
1个回答
0
投票

你把值放在登录名中,但在它之前你是插入值所以错误来了

if (competencies_title.equals( "Genetic Competencies")) {

                Bundle bundle = new Bundle();
                loginName = login_name.getText().toString();
                recommendedmodule = recommendedModules.getText().toString();
                studentcomments = comments.getText().toString();
                bundle.putString("name", loginName);
                databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
                Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
                bundle.putString("description", "You have answered all questions for Genetic Competencies");
                intent.putExtra("answer1", answerName1);
                intent.putExtra("answer2", answerName2);
                intent.putExtra("answer3", answerName3);
                intent.putExtra("answer4", answerName4);
                intent.putExtra("recommendedModules", recommendedmodule);
                intent.putExtra("comments", studentcomments);
                intent.putExtras(bundle);
                startActivity(intent);
            }
            if (competencies_title.equals("Technical Competencies")) {

                Bundle bundle = new Bundle();
                loginName = login_name.getText().toString();
                recommendedmodule = recommendedModules.getText().toString();
                studentcomments = comments.getText().toString();
                bundle.putString("name", loginName);
                databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
                Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
                bundle.putString("description", "You have answered all questions for Technical Competencies");
                intent.putExtra("answer1", answerName1);
                intent.putExtra("answer2", answerName2);
                intent.putExtra("answer3", answerName3);
                intent.putExtra("answer4", answerName4);
                intent.putExtra("recommendedModules", recommendedmodule);
                intent.putExtra("comments", studentcomments);
                intent.putExtras(bundle);
                startActivity(intent);
            }
© www.soinside.com 2019 - 2024. All rights reserved.