2016-06-20 19 views
-1

プロジェクトで作業中です。学生の詳細をsqliteデータベースに挿入したいのですが、アンドロイドモニターに「テーブルAttendanceListには姓という名前の列がありません」というエラーが表示され、その列があります。私は何日間も立ち往生しています、私は助けてください。sqliteデータベースへのデータの挿入エラー

ここに私のコードです。 DatabaseHandler.java

public class DatabaseHandler extends SQLiteOpenHelper { 
// All Static variables 
// Database Version 
private static final int DATABASE_VERSION = 1; 

// Database Name 
private static final String DATABASE_NAME = "StudentAttendance"; 

// Contacts table name 
private static final String TABLE_AttendanceList = "AttendanceList"; 

// Contacts Table Columns names 
private static final String KEY_surname = "surname"; 
private static final String KEY_ID = "id"; 
private static final String KEY_reg_no = "reg_no"; 
private static final String KEY_firstname = "firstname"; 
private static final String KEY_lastname = "lastname"; 


public DatabaseHandler(Context context) { 
    super(context, DATABASE_NAME, null, DATABASE_VERSION); 
} 

// Creating Tables 
@Override 
public void onCreate(SQLiteDatabase db) { 
    String CREATE_AttendanceList_TABLE = "CREATE TABLE " + TABLE_AttendanceList + "(" 
      + KEY_ID + " INTEGER PRIMARY KEY," 
      + KEY_reg_no + " TEXT" 
      + KEY_firstname + " TEXT" 
      + KEY_lastname + "TEXT" 
      + KEY_surname + "TEXT" + ")"; 
    db.execSQL(CREATE_AttendanceList_TABLE); 
} 

// Upgrading database 
@Override 
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 
    // Drop older table if existed 
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_AttendanceList); 

    // Create tables again 
    onCreate(db); 
} 

/** 
* All CRUD(Create, Read, Update, Delete) Operations 
*/ 

// Adding new contact 
void addAttendanceList (AttendanceList AttendanceList) { 
    SQLiteDatabase db = this.getWritableDatabase(); 

    ContentValues values = new ContentValues(); 
    values.put(KEY_ID, AttendanceList.getID()); 
    values.put(KEY_reg_no, AttendanceList.getRegNo()); // RegNo 
    values.put(KEY_firstname, AttendanceList.getFirstname()); 
    values.put(KEY_lastname, AttendanceList.getLastname()); // lasttname 
    values.put(KEY_surname, AttendanceList.getSurname());// surname 

    // Inserting Row 
    db.insert(TABLE_AttendanceList,null,values); 
    db.close(); // Closing database connection 
} 

// Getting single contact 
AttendanceList getAttendanceList(int id) { 
    SQLiteDatabase db = this.getReadableDatabase(); 

    Cursor cursor = db.query(TABLE_AttendanceList, new String[] { KEY_ID, 
        KEY_reg_no, KEY_firstname, KEY_lastname, KEY_surname }, KEY_ID + "=?", 
      new String[] { String.valueOf(id) }, null, null, null, null); 
    if (cursor != null) 
     cursor.moveToFirst(); 

    AttendanceList AttendanceList = new AttendanceList(Integer.parseInt(cursor.getString(0)), 
      cursor.getString(1), cursor.getString(2), cursor.getString(3),cursor.getString(4)); 
    // return AttendanceList 
    return AttendanceList; 
} 

// Getting All details 
public List<AttendanceList> getAllAttendanceList() { 
    List<AttendanceList> contactList = new ArrayList<AttendanceList>(); 
    // Select All Query 
    String selectQuery = "SELECT * FROM " + TABLE_AttendanceList; 

    SQLiteDatabase db = this.getWritableDatabase(); 
    Cursor cursor = db.rawQuery(selectQuery, null); 

    // looping through all rows and adding to list 
    if (cursor.moveToFirst()) { 
     do { 
      AttendanceList AttendanceList = new AttendanceList(); 
      AttendanceList.setID(Integer.parseInt(cursor.getString(0))); 
      AttendanceList.setRegNo(cursor.getString(1)); 
      AttendanceList.setFirstname(cursor.getString(2)); 
      AttendanceList.setLastname(cursor.getString(3)); 
      AttendanceList.setSurname(cursor.getString(4)); 
      // Adding Attendance to list 
      contactList.add(AttendanceList); 
     } while (cursor.moveToNext()); 
    } 

    // return Attendancelist 
    return contactList; 
} 

// Updating single Attendance List 
public int updateContact(AttendanceList AttendanceList) { 
    SQLiteDatabase db = this.getWritableDatabase(); 

    ContentValues values = new ContentValues(); 
    values.put(KEY_reg_no, AttendanceList.getRegNo()); 
    values.put(KEY_firstname, AttendanceList.getFirstname()); 
    values.put(KEY_lastname, AttendanceList.getLastname()); 
    values.put(KEY_surname, AttendanceList.getSurname()); 

    // updating row 
    return db.update(TABLE_AttendanceList, values, KEY_ID + " = ?", 
      new String[] { String.valueOf(AttendanceList.getID()) }); 
} 

// Deleting single List item 
public void deleteListItem(AttendanceList AttendanceList) { 
    SQLiteDatabase db = this.getWritableDatabase(); 
    db.delete(TABLE_AttendanceList, KEY_ID + " = ?", 
      new String[] { String.valueOf(AttendanceList.getID()) }); 
    db.close(); 
} 


// Getting List Count 
public int getListCount() { 
    String countQuery = "SELECT * FROM " + TABLE_AttendanceList; 
    SQLiteDatabase db = this.getReadableDatabase(); 
    Cursor cursor = db.rawQuery(countQuery, null); 
    cursor.close(); 

    // return count 
    return cursor.getCount(); 
} 

}

StudentTake100Activity.java

public class StudentTake100Activity extends AppCompatActivity { 
private ListView lvStudentlist; 
private StudentListAdapter adapter; 
private List<StudentList> mStudentList; 
private CheckBox checkBox; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_student_take100); 

    lvStudentlist= (ListView) findViewById(R.id.listview_studentlist); 


    final DatabaseHandler db = new DatabaseHandler(this); 

    mStudentList = new ArrayList<>(); 
    //Add sample data for list 
    //We can get data from DB, webservice here 
    mStudentList.add(new StudentList(1, "U11EE1001", "Bargo","S.","Mayafi")); 
    mStudentList.add(new StudentList(2, "U11EE1002", "Barnsbas","Snake.","Maciji")); 
    mStudentList.add(new StudentList(3, "U11EE1004", "Adamu","Tanko.","Sadau")); 
    mStudentList.add(new StudentList(4, "U11EE1005", "Munzali","","Cire Tallafi")); 


    //Init adapter 
    adapter = new StudentListAdapter(getApplicationContext(), mStudentList); 
    lvStudentlist.setAdapter(adapter); 
    checkBox = (CheckBox) findViewById(R.id.checkBox); 

    lvStudentlist.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     @Override 
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 

      StudentList studentList = (StudentList)parent.getItemAtPosition(position); 

      String reg_no = studentList.getReg_no(); 
      String firstname = studentList.getFirstname(); 
      String lastname = studentList.getLasttname(); 
      String surname = studentList.getSurname(); 

      db.addAttendanceList(new AttendanceList(reg_no,firstname,lastname,surname)); 


     } 
    }); 

} 

}

AttendaneList.java

public class AttendanceList { 
//private variables 
int _id; 
String _reg_no; 
String _firstname; 
String _lastname; 
String _surname; 

// Empty constructor 
public AttendanceList(){ 

} 
// constructor 
public AttendanceList(int id, String _reg_no, String _firstname, String _lastname, String _surname){ 
    this._id = id; 
    this._reg_no = _reg_no; 
    this._firstname = _firstname; 
    this._lastname = _lastname; 
    this._surname = _surname; 
} 

// constructor 
public AttendanceList(String _reg_no, String _firstname, String _lastname, String _surname){ 
    this._reg_no = _reg_no; 
    this._firstname = _firstname; 
    this._lastname = _lastname; 
    this._surname = _surname; 
} 
// getting ID 
public int getID(){ 
    return this._id; 
} 

// setting id 
public void setID(int id){ 
    this._id = id; 
} 

// getting regNo 
public String getRegNo(){ 
    return this._reg_no; 
} 

// setting regNo 
public void setRegNo(String reg_no){ 
    this._reg_no = reg_no; 
} 

// getting firstname 
public String getFirstname(){ 
    return this._firstname; 
} 

// setting firstname 
public void setFirstname(String firstname){ 
    this._firstname = firstname; 
} 

// getting lastname 
public String getLastname(){ 
    return this._lastname; 
} 

// setting lastname 
public void setLastname(String lastname){ 
    this._lastname = lastname; 
} 
// getting surname 
public String getSurname(){ 
    return this._surname; 
} 

// setting surname 
public void setSurname(String surname){ 
    this._surname = surname; 
} 

}

logcat image

syntax error

06-22 10:58:04.576 2936-2961/com.sunusi2sim.mobileattendance E/Surface: getSlotFromBufferLocked: unknown buffer: 0xeeab85e0 
06-22 10:58:05.957 2936-2936/com.sunusi2sim.mobileattendance E/SQLiteLog: (1) near ")": syntax error 
06-22 10:58:05.959 2936-2936/com.sunusi2sim.mobileattendance E/InputEventReceiver: Exception dispatching input event. 
06-22 10:58:05.959 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TABLE AttendanceList(id INTEGER PRIMARY KEY,reg_no TEXT,firstname TEXT,lastname TEXT,surname TEXT,) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.sunusi2sim.mobileattendance.DatabaseHandler.onCreate(DatabaseHandler.java:47) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.sunusi2sim.mobileattendance.DatabaseHandler.addAttendanceList(DatabaseHandler.java:66) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.sunusi2sim.mobileattendance.StudentTake100Activity$1.onItemClick(StudentTake100Activity.java:54) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.widget.AdapterView.performItemClick(AdapterView.java:310) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.widget.AbsListView.performItemClick(AbsListView.java:1145) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.widget.AbsListView$PerformClick.run(AbsListView.java:3042) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.widget.AbsListView.onTouchUp(AbsListView.java:3891) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.widget.AbsListView.onTouchEvent(AbsListView.java:3656) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.View.dispatchTouchEvent(View.java:9294) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2547) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.app.Activity.dispatchTouchEvent(Activity.java:2765) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.View.dispatchPointerEvent(View.java:9514) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
06-22 10:58:05.961 2936-2936/com.sunusi2sim.mobileattendance E/MessageQueue-JNI: at android.view.ViewRootImpl$InputS 

ViewAttendanceActivity

public class ViewAttendanceActivity extends AppCompatActivity { 
private ListView lvStudentlist; 
private StudentListAdapter adapter; 
private List<StudentList> mStudentList; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_view_attendance); 

    lvStudentlist= (ListView) findViewById(R.id.listview_studentlist); 

    DatabaseHandler db = new DatabaseHandler(this); 

    SQLiteDatabase connection; 
    connection = db.getReadableDatabase(); 

    Cursor result=connection.rawQuery("SELECT * FROM AttendanceList", null);// database query for all AttendanceList in your table 
    while(result.moveToNext()) 
     mStudentList.add(new StudentList(result.getInt(0),result.getString(1),result.getString(2),result.getString(3),result.getString(4))); 

    mStudentList = new ArrayList<>(); 

    adapter = new StudentListAdapter(getApplicationContext(), mStudentList); 
    lvStudentlist.setAdapter(adapter); 


} 

}

エラー

06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:致命的除外:メイン 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:プロセス:com.sunusi2sim.mobileattendance、PID:1650 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:java.lang.RuntimeException:アクティビティを開始できませんComponentInfo {com.sunusi2sim.mobileattendance /com.sunusi2sim.mobileattendance.ViewAttendanceActivity}:java.lang.NullPointerException:nullオブジェクト参照でインタフェースメソッド 'boolean java.util.List.add(java.lang.Object)'を呼び出そうとしています 06-24 17:41 :05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) 06-24 17:41:05.354 1650-165 0/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:and android .app.ActivityThread.-wrap11(ActivityThread.java) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344) ) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.os.Handler.dispatchMessage(Handler.java:102) 06-24 17:41:05.354 1650-1650 /com.sunusi2sim.mobileattendance E/AndroidRuntime:android.os.Looper.loop(Looper.java:148) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:at android。 app.ActivityThread.main(ActivityThread.java:5417) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:java.lang.reflect.Method.invoke(ネイティブメソッド) 06-24 17:41:05.354 1650-1650/com .sunusi2sim.mobileattendance E/AndroidRuntime:com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime :com.androidで。内部メソッド:ZygoteInit.main(ZygoteInit.java:616) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:原因:java.lang.NullPointerException:インタフェースメソッドを呼び出そうとしていますnullのオブジェクト参照で 'boolean java.util.List.add(java.lang.Object)' 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:at com.sunusi2sim.mobileattendance .ViewAttendanceActivity.onCreate(ViewAttendanceActivity.java:31) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.Activity.performCreate(Activity.java:6237) 06 -24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 06-24 17:41:05.354 1650-1650/com。 sunusi2sim.mobileattendance E/AndroidRuntime:at a ndroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) ) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread.-wrap11(ActivityThread.java) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:and android .os.Handler.dispatchMessage(Handler.java:102) 06-24 17:41:05.354 1650-1650/com.sunusi2sim.mobileattendance E/AndroidRuntime:android.os.Looper.loop(Looper.java:148)

+0

logcatはどこですか?投稿してください。 – Vucko

+0

これは、人々がSQLを書くことを許可してはいけない理由です。 – njzk2

+0

アプリケーションのこの後の「姓」列を追加しましたか? はいの場合は、デバイスからアプリケーションを完全にアンインストールしてからもう一度インストールして実行してください。 – Vickyexpert

答えて

2

あなたの作成テーブルクエリはそれを台無しにしています。列名とその型は間にスペースを入れ、コンマもありません。これを使用する

@Override 
public void onCreate(SQLiteDatabase db) { 
    String CREATE_AttendanceList_TABLE = "CREATE TABLE " + TABLE_AttendanceList + "(" 
     + KEY_ID + " INTEGER PRIMARY KEY," 
     + KEY_reg_no + " TEXT," 
     + KEY_firstname + " TEXT," 
     + KEY_lastname + " TEXT," 
     + KEY_surname + " TEXT" + ")"; 
    db.execSQL(CREATE_AttendanceList_TABLE); 
} 

最初にアプリをアンインストールしてから、更新されたコードを実行する必要があります。

+0

ありがとう...私は、プロジェクトをクリアして再構築しましたが、logcatにも同じエラーがあります。 –

+0

あなたのデバイスから古いアプリをインストールしましたか?古いアプリをインストールする必要があります。 – Rohit5k2

+0

ありがとうございます。私は今、より多くのエラー(構文エラー)を持っていますが、私は "テーブルAttendanceListは、姓の名前の列を持っていない"と表示されません幸せです。 –

関連する問題