package com.db;
t.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
public class DBHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "contact_db";
// 定义初始版本号为1
private static final int VERSION = 1;
// 单例模式
private static DBHelper dbHelper = null;
private SQLiteDatabase sqlDb;
// 构造函数
public DBHelper(Context context, String name, CursorFactory factory,
int version) {
super(context, DB_NAME, factory, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
c型卡环 String sql="create table UserContact(_id integer primary key autoincrement,img_id integer,name text not null,mobilePhone text,homePhone text,officePhone text,company text,position text,address text,remark text,time text,weekey integer)";
// 执行sql命令
db.execSQL(sql);
}
// 提供更新数据库的方法
mp3制作 @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String sql = "drop table if exists UserContact ";
db.execSQL(sql);
// 重新执行
Create(db);
}
public void execsql(String sql,Object[] nums){
SQLiteDatabase WritableDatabase();
db.execSQL(sql, nums);
}
public Cursor query(String sql,String[] nums){
SQLiteDatabase ReadableDatabase();
Cursor c=db.rawQuery(sql, nums);
return c;
}
}
st;
SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;扁蓿豆
import java.util.Map;
import com.db.DBHelper;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
t.DialogInterface;
t.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
汽车投影import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
led节能灯制作import android.widget.Button;
import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
public class AddUser extends Activity {
private Button save_btn;
private Button cancel_btn;
private DBHelper db;
private int imgid=0;
private ImageView imageview;
private Gallery gallery;
// 依次获取所有控件
private EditText txt_name,txt_mobilePhone,txt_officePhone,txt_homePhone,txt_position,txt_company,txt_address,txt_remark;
private ImageButton img_btn;
private int[] images = { R.drawable.icon, R.drawable.a1,
R.drawable.a2, R.drawable.a3, R.drawable.a4,
R.drawable.a5, R.drawable.a6, R.drawable.a7,
R.drawable.a8, R.drawable.a9, R.drawable.image10 };
private int contact_id=0;
private int ImgId = 0,text=0;
protected void onCreate(Bundle savedInstanceState) {
Create(savedInstanceState);
setContentView(R.layout.add_contact);
init();
db=new DBHelper(this,null,null,0);
// 加载所有控件
img_btn=(ImageButton)findViewById(R.id.btn_img);
save_btn=(Button)findViewById(R.id.btn_save);
img_btn.setOnClickListener(new MyImageBtnListener());
save_btn.setOnClickListener(new MySaveBtnListener());
contact_id = Intent().getIntExtra("id", 0);
initContactInfo(contact_id);
}
private void init(){
txt_name=(EditText)findViewById(_name);
txt_mobilePhone=(EditText)findViewById(_mobilePhone);
txt_officePhone=(EditText)findViewById(_officePhone);
txt_homePhone=(EditText)findViewById(_homePhone);
txt_position=(EditText)findViewById(_position);
94crw txt_company=(EditText)findViewById(_company);
txt_address=(EditText)findViewById(_address);
txt_remark=(EditText)findViewById(_remark);
}
// 图片按钮事件
private class MyImageBtnListener implements OnClickListener {
public void onClick(View v) {
View vv=getLayoutInflater().inflate(R.layout.face_dialog, null);
gallery=(Gallery) vv.findViewById(R.id.face_dialog_gallery);
imageview=(ImageView) vv.findViewById(R.id.face_dialog_img);
gallery.setAdapter(new imageAdapter());
gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
imgid=position;
ImgId=position;
imageview.setImageResource(images[position%images.length]);
}
public void onNothingSelected(AdapterView<?> arg0) {