사용자 정보입력에 관한 db를 생성하려는데
table customers has no column named lunarcalendar 이렇게 오류가 뜨네요 ㅠ.ㅠ
글자수제한때문에 지웠는데
COLUMN_ID 이부분은 string선언 문제없이 했습니다!
DBManager.java
private static final String DATABASE_CREATE = "create table "
+ Database_Name
+ "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_Name + " text not null, "
+ COLUMN_date + " text not null, "
+ COLUMN_sort + " text not null, "
+COLUMN_lunar + "text, "
+ COLUMN_alarm + " text not null,"
+COLUMN_number + " INTEGER , "
+COLUMN_memo + " text"
+ ");";
public DBManager(Context context){
super(context,Database_Name, null , 1);
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(DATABASE_CREATE);
}
RegisterActivity.java 저장버튼을 누르면 디비 저장되게끔 한부분입니다
public void save(View v){
EditText et_name = (EditText)findViewById(R.id.name);
String str_name = et_name.getText().toString();
TextView et_date = (TextView)findViewById(R.id.pickDate);
String str_date = et_date.getText().toString();
RadioGroup rg_sort = (RadioGroup)findViewById(R.id.radiogroup_sort);
RadioButton rb_birth = (RadioButton)findViewById(R.id.birthday);
RadioButton rb_anniver = (RadioButton)findViewById(R.id.anniversary);
RadioButton rb_etc = (RadioButton)findViewById(R.id.etc);
String str_sort ="";
if(rg_sort.getCheckedRadioButtonId() == R.id.birthday){
str_sort = rb_birth.getText().toString();
}
else if(rg_sort.getCheckedRadioButtonId() == R.id.anniversary){
str_sort = rb_anniver.getText().toString();
}
else if (rg_sort.getCheckedRadioButtonId() == R.id.etc) {
str_sort = rb_etc.getText().toString();
}
CheckBox chk_lunnar = (CheckBox)findViewById(R.id.lunnar);
String str_lunar="";
if(chk_lunnar.isChecked()){
str_lunar = chk_lunnar.getText().toString();
}
Spinner tx_alarm = (Spinner)findViewById(R.id.alarmSpinner);
String str_alarm = tx_alarm.getSelectedItem().toString();
TextView tv_phonenumber = (TextView)findViewById(R.id.phonenumber);
String str_number = tv_phonenumber.getText().toString();
TextView tv_memo = (TextView)findViewById(R.id.memo);
String str_memo = tv_memo.getText().toString();
try{
dbmanager = new DBManager(this);
sqlitedb =dbmanager.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(dbmanager.COLUMN_lunarcalendar, str_lunar);
values.put(dbmanager.COLUMN_alarm, str_alarm);
values.put(dbmanager.COLUMN_number, str_number);
values.put(dbmanager.COLUMN_memo, str_memo);
long newRowId = sqlitedb.insert("customers",null,values);
sqlitedb.close();
dbmanager.close();
}catch (Exception e){Toast.makeText(this,"DB등록실패",Toast.LENGTH_LONG).show();}
Intent n = new Intent(this,MainActivity.class);
startActivity(n);
}