제가 지금 SQLite를 건들여보고있는데 상당히 어렵네요;;;
editText 2개에 id와 password를 입력 받고 버튼을 누르면 데이터베이스 테이블에
저장되게끔 하려고 하고있는데 에러는 검출되지 않는데 어디서 문제인지 잘 모르겠습니다.
소스를 올려볼테니 잘못된 부분좀 지적해주세요.
package net.IdPassEx;
import android.app.Activity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
public class IdPassEx extends Activity {
IdpassHelper mHelper;
private Button btn;
private EditText edit;
SQLiteDatabase db;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
edit = (EditText)findViewById(R.id.idedit);
edit = (EditText)findViewById(R.id.passedit);
btn = (Button)findViewById(R.id.creat);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
db.execSQL("Insert into manage id calues ('"+edit.getText()+"')");
//db.execSQL("Insert into manage pass calues ('"+edit.getText()+"')");
}
});
}
}
abstract class IdpassHelper extends SQLiteOpenHelper{
public IdpassHelper(Context context){
super(context, "manage", null, 1);
}
public void onCreate(SQLiteDatabase arg0){
arg0.execSQL("CREATE TABLE manage(_id INSERT PRIMARY KEY AUTOINCREMENT,"+ "id TEXT, pass TEXT);");
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText android:text=""
android:id="@+id/idedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText android:text=""
android:id="@+id/passedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<Button android:text="생성"
android:id="@+id/creat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Helper로 부터 DB를 받아오는 문장은 어디갔나요?