학교에서 간단하게 테스트 할때는 잘됫엇는데 DB에 속성하나 추가하고 폼에서 입력된내용 받아서 DB저장하도록 수정해서 집에서 테스트해보니까 갑자기 강제종료되는데
도저히 이유를 못찾겟습니다 검색해보니까 매니페스트 등록이 안된거라고해서 다시확인햇는데 확실히 등록되있구요
메인화면에서 아래 파일로 이동하게되면 에러가납니다.
package com.example.dbbasicex1;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;
public class CustomerReg extends Activity {
String[] interested ={"관심분야","없음","경영/경제",
"과학","스포츠","여행","예술","외국어","요리","컴퓨터"};
String selint;
EditText ed_name = (EditText)findViewById(R.id.reditText1);
RadioGroup rg_sex = (RadioGroup)findViewById(R.id.rradioGroup1);
CheckBox ck_sms = (CheckBox)findViewById(R.id.rcheckBox1);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.join_form);
//목록화면으로
Button bt_dr,rebtn;
Spinner sp = (Spinner)findViewById(R.id.rspinner1);
ArrayAdapter<String> adp = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,interested);
sp.setAdapter(adp);
sp.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
selint = interested[position];
Toast.makeText(getApplicationContext(), interested[position], 1000).show();
}@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
selint = interested[1];
}
});
bt_dr = (Button)findViewById(R.id.rbutton1);
bt_dr.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String name,sex,sms;
// TODO Auto-generated method stub
try{
name = ed_name.getText().toString();
sex = "";
if(rg_sex.getCheckedRadioButtonId() == R.id.rradio0)
{
sex = "남";
}
else if(rg_sex.getCheckedRadioButtonId() == R.id.rradio1)
{
sex = "여";
}
sms ="";
if(ck_sms.isChecked())
{
sms ="SMS";
}
DBManeger dbmgr = new DBManeger(getApplicationContext());
SQLiteDatabase sdb = dbmgr.getWritableDatabase();
String sql = "insert into customers values ('" + name + "','" + sex + "','" + sms + "','" + selint + "')";
sdb.execSQL(sql);
dbmgr.close();
Toast.makeText(getApplicationContext(), "입력되었습니다.", 1000).show();
}
catch(Exception e)
{
Toast.makeText(getApplicationContext(), "예외발생 : " + e, 1000).show();
}
}
});
rebtn = (Button) findViewById(R.id.returnbtn);
rebtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent it = new Intent(getApplicationContext(),MainActivity.class);
startActivity(it);
finish();
}
});
}
}
이건 로그캣에서 제일 처음 오류입니다.
FATAL EXCEPTION: main
Process: com.example.dbbasicex1, PID: 27029
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.dbbasicex1/com.example.dbbasicex1.CustomerReg}: java.lang.NullPointerException
나머지부분 로그캡쳐추가합니다