마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

디비 핸들러 위치에 관련해서 질문드립니다 ㅠ

0 추천
dialog1.setButton(titleButtonOk, new DialogInterface.OnClickListener(){
    public void onClick(DialogInterface dialog, int which){ // 확인버튼 누르면 하는 행동
    dbHandler = DBHandler.open(this);
    try {                          
               long re = dbHandler.insert(  
                       et1.getText().toString(),   
                       getText(r).toString());  
                 
                   
                   cursor = dbHandler.selectAll();  
                   arr = new String[cursor.getCount()];  
                   int count = 0;  
                   while(cursor.moveToNext()){  
                       String code = cursor.getString(0);  
                       String sang = cursor.getString(1);  
                       String price = cursor.getString(2);  
                       arr[count] = code + " " + sang + " " + price;  
                       count++;  
                   }  
                   cursor.close();  
                     
                 
                           
       } catch (Exception e) {  
           Log.i("disp", "err:" + e);  
       }
   
    data = et1.getText().toString(); // 데이터는 에디트텍스트를 통해 입력받은 값    
    dialog.dismiss();
    mp4.start();
    Vibrator vibe = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
    vibe.vibrate(100);
    Intent intent3 = new Intent(MySubActivity.this, GameActivity.class);
    startActivity(intent3);
    finish();
    }
    });
 
디비핸들러를 넣으면 open에서 잘못되었다고 나오네요...
The method open(Context) in the type DBHandler is not applicable for the arguments (new DialogInterface.OnClickListener(){})
에러메시지는 이렇게 나옵니다. 다이얼로그 보다 더 상위 메소드에 넣으면 에러는 안나고 실행도 잘 되는데
DB에 데이터 값이 안들어갑니다... 무엇이 문제일까요...
코딩잘하고싶다 (980 포인트) 님이 2013년 7월 2일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...