Index: trunk/22.DBTest/default.properties =================================================================== --- trunk/22.DBTest/default.properties (revision 56) +++ trunk/22.DBTest/default.properties (revision 56) @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=android-7 Index: trunk/22.DBTest/.classpath =================================================================== --- trunk/22.DBTest/.classpath (revision 56) +++ trunk/22.DBTest/.classpath (revision 56) @@ -0,0 +1,7 @@ + + + + + + + Index: trunk/22.DBTest/.project =================================================================== --- trunk/22.DBTest/.project (revision 56) +++ trunk/22.DBTest/.project (revision 56) @@ -0,0 +1,33 @@ + + + 22.DBTest + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + Index: trunk/22.DBTest/AndroidManifest.xml =================================================================== --- trunk/22.DBTest/AndroidManifest.xml (revision 56) +++ trunk/22.DBTest/AndroidManifest.xml (revision 56) @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + Index: trunk/22.DBTest/src/soo/data/db/DBList.java =================================================================== --- trunk/22.DBTest/src/soo/data/db/DBList.java (revision 56) +++ trunk/22.DBTest/src/soo/data/db/DBList.java (revision 56) @@ -0,0 +1,16 @@ +package soo.data.db; + +import android.app.ListActivity; +import android.os.Bundle; +import android.widget.EditText; + +public class DBList extends ListActivity { + EditText et; + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.list); + + et = (EditText)findViewById(R.id.editTest01); + } +} Index: trunk/22.DBTest/src/soo/data/db/DBTest.java =================================================================== --- trunk/22.DBTest/src/soo/data/db/DBTest.java (revision 56) +++ trunk/22.DBTest/src/soo/data/db/DBTest.java (revision 56) @@ -0,0 +1,167 @@ +package soo.data.db; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +public class DBTest extends Activity +implements OnClickListener +{ + /** Called when the activity is first created. */ + private Button createB,dropB,insertB,updateB,deleteB,selectB; + private EditText et1,et2,et3; + private SQLiteDatabase db; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + createB = (Button)findViewById(R.id.button01); + dropB = (Button)findViewById(R.id.button02); + insertB = (Button)findViewById(R.id.button03); + updateB = (Button)findViewById(R.id.button04); + deleteB = (Button)findViewById(R.id.button05); + selectB = (Button)findViewById(R.id.button06); + + createB.setOnClickListener(this); + dropB .setOnClickListener(this); + insertB.setOnClickListener(this); + updateB.setOnClickListener(this); + deleteB.setOnClickListener(this); + selectB.setOnClickListener(this); + + et1 = (EditText)findViewById(R.id.editText01); + et2 = (EditText)findViewById(R.id.editText02); + et3 = (EditText)findViewById(R.id.editText03); + + openDb(); + } + + private final static String DB_NAME="test.db"; + private final static int DB_MODE = Context.MODE_PRIVATE; + private final static String TABLE_NAME="ADDRESS"; + private void openDb(){ + db = openOrCreateDatabase(DB_NAME, DB_MODE, null); + showToast("DB("+DB_NAME+") ��� 諛��대┝"); + + //createTable(); + } + + private void createTable(){ + String sql = "create table "+TABLE_NAME + + "(SEQ integer primary key autoincrement," + + " NAME text not null,ADDR,DDATE date)"; + + try{ + db.execSQL(sql); + showToast("���釉�"+TABLE_NAME+") ��� ���"); + }catch(SQLException se){ + Log.e("createTable",se.toString()); + } + } + + private void dropTable(){ + String sql = "drop table "+TABLE_NAME; + + try{ + db.execSQL(sql); + showToast("���釉�"+TABLE_NAME+") ��� ���"); + }catch(SQLException se){ + Log.e("dropTable",se.toString()); + } + } + + private void insertData(String name,String addr){ + String sql = "insert into "+TABLE_NAME+"(NAME,ADDR,DDATE) " + + "values ('"+name+"','"+addr+"',date('now'))"; + try{ + db.execSQL(sql); + showToast("���(insert) ���"); + }catch(SQLException se){ + Log.e("insertData",se.toString()); + } + + } + + private void updateData(String name,String addr){ + String sql = "update "+TABLE_NAME+" " + + " set addr='"+addr+"'," + + " ddate=date('now') " + + " where name ='"+name+"'"; + try{ + db.execSQL(sql); + showToast("���(update) ���"); + }catch(SQLException se){ + Log.e("updateData",se.toString()); + } + + } + + private void deleteData(String name,String addr){ + String sql = "delete from "+TABLE_NAME+" " + + " where name ='"+name+"'"; + try{ + db.execSQL(sql); + showToast("���(delete) ���"); + }catch(SQLException se){ + Log.e("deleteData",se.toString()); + } + + } + + private void showToast(String msg){ + Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); + //Toast.makeText(AlertDialog.this, "���ル�?!!", Toast.LENGTH_SHORT).show(); + } + + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + if(v==createB){ + createTable(); + }else if(v==dropB){ + dropTable(); + }else if(v==insertB){ + String name = et2.getText().toString(); + if(name !=null) name=name.trim(); + if(name.equals("")){ + showToast("�대���諛��������댁� �⑸���"); + return; + } + String addr = et3.getText().toString(); + insertData(name,addr); + }else if(v==updateB){ + String name = et2.getText().toString(); + if(name.equals("")){ + showToast("�대���諛��������댁� �⑸���"); + return; + } + String addr = et3.getText().toString(); + updateData(name,addr); + }else if(v==deleteB){ + String name = et2.getText().toString(); + if(name.equals("")){ + showToast("�대���諛��������댁� �⑸���"); + return; + } + String addr = et3.getText().toString(); + deleteData(name,addr); + }else if(v==selectB){ + Intent i = new Intent(this,DBList.class); + startActivityForResult(i,1 ); //���瑜�二쇰� 寃���� 1����껌肄��(requestCode) �대�.. + } + } + + +} Index: trunk/22.DBTest/res/values/strings.xml =================================================================== --- trunk/22.DBTest/res/values/strings.xml (revision 56) +++ trunk/22.DBTest/res/values/strings.xml (revision 56) @@ -0,0 +1,5 @@ + + + Hello World, DBTest! + DBTest + Index: trunk/22.DBTest/res/layout/main.xml =================================================================== --- trunk/22.DBTest/res/layout/main.xml (revision 56) +++ trunk/22.DBTest/res/layout/main.xml (revision 56) @@ -0,0 +1,71 @@ + + +