2017-07-18 8 views
-1

私は2つのアクティビティを持っています。データベースヘルパーとその他が主なアクティビティです。 sytaxエラーはありませんが、私はAcceptボタン(accButton)を押すたびに、私のアプリは動作を停止します。 ありがとうございました。AccButton(AcceptButton)をクリックするとSQLiteの動作が停止する

コード主な活動でDBhelperクラスの

@Override 
    public void onCreate(SQLiteDatabase db) { 
     db.execSQL("create table" + TABLE_NAME + "create table LMSLiteDB(ID text primary key not null," + 
       "Password text not null, Name text not null, VU-Email text not null, City text not null," + 
       "Country text not null, Selected_Course text not null);"); 

    } 

    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 


     db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME); 
     onCreate(db); 
    } 

    public boolean insertValues(String id, String autoPass, String name, String mail, String city, String contry , String selectedCourse) { 
     SQLiteDatabase db = this.getWritableDatabase(); 
     ContentValues values = new ContentValues(); 
     values.put(COLUMN_ID, id); 
     values.put(COLUMN_PASSWORD, autoPass); 
     values.put(COLUMN_Name, name); 
     values.put(COLUMN_VUEmail, mail); 
     values.put(COLUMN_CITY, city); 
     values.put(COLUMN_COUNTRY, contry); 
     values.put(COLUMN_SELECTEDCOURSE, selectedCourse); 

     long result = db.insert(TABLE_NAME, null, values); 
     if (result == -1) 
      return false; 
     else 
      return true; 
    } 

コード

public void onAccClick(View view) { 

     TextView tfName = (TextView) findViewById(R.id.fName); 
     TextView tEmail = (TextView) findViewById(R.id.vuEmail); 
     TextView tId = (TextView) findViewById(R.id.id); 
     TextView tPassword = (TextView) findViewById(R.id.password); 
     TextView tCity = (TextView) findViewById(R.id.city); 
     TextView tContry = (TextView) findViewById(R.id.contry); 
     TextView tItem = (TextView) findViewById(R.id.item); 


     boolean isInserted = db.insertValues(tId.getText().toString(), tPassword.getText().toString(), tfName.getText().toString(), 
       tEmail.getText().toString(), tCity.getText().toString(), tContry.getText().toString(), 
       tItem.getText().toString()); 
     if (isInserted = true) { 
      Toast.makeText(ACCEPT.this, "Data Inserted", Toast.LENGTH_LONG).show(); 
     } else { 
      Toast.makeText(ACCEPT.this, "Data not Inserted", Toast.LENGTH_LONG).show(); 
     } 
    } 
} 
+3

'私のアプリはworking.'ショーログとコード –

+0

の関連部分を停止するには、として仕事を始めたことがない "作業停止します"問題の説明。 [質問]、[mcve]を構築する方法、特に[なぜ誰かが私を助けることができますか?]は実際の質問ではありませんか?](http://meta.stackoverflow.com/q/284236) – EJoshuaS

答えて

0

私はあなたのテーブルが正しく作成されていないと思います。 create table文を更新します。

用途:

@Override 
    public void onCreate(SQLiteDatabase db) { 
     db.execSQL("create table " + TABLE_NAME + " (ID text primary key not null, " + 
       "Password text not null, Name text not null, VU-Email text not null, City text not null," + 
       " Country text not null, Selected_Course text not null);"); 

    } 

の代わりに:

@Override 
    public void onCreate(SQLiteDatabase db) { 
     db.execSQL("create table" + TABLE_NAME + "create table LMSLiteDB(ID text primary key not null," + 
       "Password text not null, Name text not null, VU-Email text not null, City text not null," + 
       "Country text not null, Selected_Course text not null);"); 

    } 
関連する問題