
AndroID和iOS的数据库都是用sqlite来实现.
一,sqlite数据库简介:
轻量级:sqlite数据库是一个轻量级的数据库,适用于少量数据的CURD;
文件本质:sqlite数据库支持大部分sql语法,允许使用SQL语句 *** 作数据库,其本质是一个文件,不需要安装启动。
数据读写:sqlite数据库打开只是一个文件的读写流。
二.简单的数据库语句知识
在androID平台上,集成了一个嵌入式关系型数据库―sqlite,sqlite3支持NulL,INTEGER,REAL(浮点数字),TEXT(字符串文本)和BLOB(二进制对象)数据类型,实际上sqlite3也接受varchar(n),char(n),decimal(p,s)等数据类型,只不过在运算或保存时会转成对应的五种数据类型.
sqlite最大的特点是你可以把各种类型的数据保存到任何字段中,而不用关心字段声明的数据类型是什么。
今天我就用一个简单的列子来说明来实现sqlite。
实例代码:
@H_404_26@import java.util.ArrayList;import java.util.Iterator;import com.hucc.huccgps.R;import androID.app.Activity;import androID.app.Dialog;import androID.content.Context;import androID.content.Intent;import androID.content.SharedPreferences;import androID.net.Uri;import androID.os.Bundle;import androID.util.Log;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEw.OnClickListener;import androID.vIEw.VIEwGroup;import androID.vIEw.Window;import androID.Widget.AdapterVIEw;import androID.Widget.AdapterVIEw.OnItemClickListener;import androID.Widget.BaseAdapter;import androID.Widget.button;import androID.Widget.EditText;import androID.Widget.ImageVIEw;import androID.Widget.ListVIEw;import androID.Widget.TextVIEw;import androID.Widget.Toast;public class MainActivity extends Activity {private static final String TAG = "JGPS/MainActivity";private TextVIEw mAdd_white = null;private ListVIEw mWhiteListVIEw = null;private Context mContext = null;private int mposition;private DBHelper mDBHelper = null;private Whitelistadapter mAdapter = null;private ArrayList<Item> mWhiteListItem = new ArrayList<Item>();@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { Log.d("JGPS/Start","onCreate"); super.onCreate(savedInstanceState); setContentVIEw(R.layout.relative_main); this.mDBHelper = new DBHelper(this); this.mContext = this; this.mWhiteListItem = new ArrayList<Item>(); this.mWhiteListVIEw = (ListVIEw)findVIEwByID(R.ID.List_vIEw); initData(); this.mWhiteListVIEw.setonItemClickListener(new OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> paramAdapterVIEw,VIEw paramVIEw,int paramInt,long paramLong) { Log.d("JGPS/MainActivity",""+paramInt); MainActivity.this.updateWhiteList((Item)MainActivity.this.mWhiteListItem.get(paramInt)); } }); if (this.mAdd_white == null) return; mAdd_white.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw arg0) { MainActivity.this.addContactList(); } }); Log.d("JGPS/end","onCreate");}private voID initData() { this.mWhiteListItem = this.mDBHelper.getrelativesList(); if (this.mWhiteListItem.size() != 3) { for (int i = 1; i < 4; i++) { Log.d("JGPS/MainActivity","initData,ID=" + i); Item localitem1 = new Item(); localitem1.setname(""); localitem1.setNumber(""); addItemToList(localitem1); updateSetting(i,""); } this.mWhiteListItem = this.mDBHelper.getrelativesList(); } Iterator localiterator = this.mWhiteListItem.iterator(); while (localiterator.hasNext()) { Item localitem2 = (Item) localiterator.next(); Log.d("JGPS/MainActivity",ID=" + localitem2.getID() + ",name = " + localitem2.getname() + ",number=" + localitem2.getNumber()); } this.mAdapter = new Whitelistadapter(this,this.mWhiteListItem); this.mWhiteListVIEw.setAdapter(mAdapter);}private voID updateSetting(int ID,String phoneNum) { switch (ID) { case 1: putSting("phone_num1",phoneNum); break; case 2: putSting("phone_num2",phoneNum); break; case 3: putSting("phone_num3",phoneNum); break; default: Log.d("JGPS/MainActivity","Wrong relative number ID"); } }private voID putSting(String paramString1,String paramString2) { SharedPreferences.Editor localEditor = getSharedPreferences("sos_config",0).edit(); localEditor.putString(paramString1,paramString2); localEditor.apply();}protected voID updateWhiteList(Item paramItem) { final Item item = paramItem; Log.d("JGPS/MainActivity","updateWhiteList------" + item.getID()); final Dialog localDialog = new Dialog(this,R.style.dialog); localDialog.show(); Window localWindow = localDialog.getwindow(); localWindow.setContentVIEw(R.layout.dialog_editor); button localbutton1 = (button) localWindow.findVIEwByID(R.ID.btn_ok); button localbutton2 = (button) localWindow.findVIEwByID(R.ID.btn_cancel); final EditText phone = (EditText)localWindow.findVIEwByID(R.ID.phone); final EditText name = (EditText)localWindow.findVIEwByID(R.ID.name); name.setText(item.getname()); phone.setText(item.getNumber()); ((TextVIEw)localWindow.findVIEwByID(R.ID.Title)).setText(R.string.edit_white); localbutton1.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { if (phone.getText().toString().trim().length() == 0) { Toast.makeText(mContext,R.string.toast_tel,2000).show(); return; } if (name.getText().toString().trim().length() == 0) { Toast.makeText(mContext,R.string.name_null,2000).show(); return; } MainActivity.this.updateContactInDB(item.getID(),name.getText().toString(),phone.getText().toString()); int ID = Integer.parseInt(item.getID()); updateSetting(ID,phone.getText().toString()); Toast.makeText(mContext,R.string.edit_success,2000).show(); localDialog.cancel(); } }); localbutton2.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { localDialog.cancel(); } });}protected voID updateContactInDB(String paramString1,String paramString2,String paramString3) { Item localitem = new Item(); localitem.setID(paramString1); localitem.setname(paramString2); localitem.setNumber(paramString3); updateItemList(localitem);}private voID updateItemList(Item paramItem) { Item localitem2; Iterator localiterator1 = this.mWhiteListItem.iterator(); while (localiterator1.hasNext()) { localitem2 = (Item) localiterator1.next(); if (localitem2.getID().equals(paramItem.getID())) { localitem2.setname(paramItem.getname()); localitem2.setNumber(paramItem.getNumber()); this.mDBHelper.updaterelativesItem(paramItem); } } Log.d("JGPS/MainActivity","updateItemInList ---------"); this.mAdapter = new Whitelistadapter(this,this.mWhiteListItem); this.mWhiteListVIEw.setAdapter(mAdapter);}private voID addContactList() { final Dialog dialog = new Dialog(this,R.style.dialog); dialog.show(); Window window = dialog.getwindow(); window.setContentVIEw(R.layout.dialog_editor); button btn1 = (button)window.findVIEwByID(R.ID.btn_ok); button btn2 = (button)window.findVIEwByID(R.ID.btn_cancel); final EditText phone = (EditText)window.findVIEwByID(R.ID.phone); final EditText name = (EditText)window.findVIEwByID(R.ID.name); btn1.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw arg0) { if (phone.getText().toString().trim().length() == 0) { Toast.makeText(mContext,2000).show(); return; } if (name.getText().toString().trim().length() == 0) { Toast.makeText(mContext,2000).show(); return; } if (MainActivity.this.mWhiteListItem.size()>3) { String str = MainActivity.this.getResources().getString(R.string.full1)+ " " + 3 + " " + MainActivity.this.getResources().getString(R.string.full2); Toast.makeText(mContext,str,2000).show(); dialog.cancel(); return; } MainActivity.this.addContactToDB(name.getText().toString(),phone.getText().toString()); dialog.cancel(); } }); btn2.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw arg0) { dialog.cancel(); } });}protected voID deleteContactFromDB(String paramString) { updateContactInDB(paramString,"",""); Log.d("JGPS/MainActivity","===addItemToList = "+paramString); int ID = Integer.parseInt(paramString); updateSetting(ID,paramString); Toast.makeText(this.mContext,R.string.delete_success,2000).show();}@OverrIDeprotected voID onStart() { Log.d("JGPS/MainActivity","onStart()"); super.onStart();}protected voID startContactIntent(int paramInt) { Log.d("JGPS/MainActivity","onClick " + paramInt); this.mposition = paramInt; Intent localintent = new Intent("androID.intent.action.PICK"); localintent.setType("vnd.androID.cursor.dir/phone_v2"); startActivityForResult(localintent,100);}protected voID addContactToDB(String paramString1,String paramString2) { Iterator localiterator = this.mWhiteListItem.iterator(); while (localiterator.hasNext()) { if(((Item)localiterator.next()).getNumber().equals(paramString2)){ Toast.makeText(mContext,R.string.replace,2000).show(); return; } } Item localitem = new Item(); localitem.setname(paramString1); localitem.setNumber(paramString2); addItemToList(localitem); Toast.makeText(mContext,2000).show();}private voID addItemToList(Item localitem) { Log.d("JGPS/MainActivity","addItemToList,name = " + localitem.getname() + ",number=" + localitem.getNumber()); this.mDBHelper.addrelativesItem(localitem); this.mWhiteListItem = this.mDBHelper.getrelativesList(); this.mAdapter = new Whitelistadapter(this,this.mWhiteListItem); this.mWhiteListVIEw.setAdapter(mAdapter);}public voID startActivityForResult(Intent paramIntent,int paramInt){ super.startActivityForResult(paramIntent,paramInt);}private class Whitelistadapter extends BaseAdapter{ private Context context; private LayoutInflater mInflater; private ArrayList<Item> ListItem; public Whitelistadapter(Context context1,ArrayList<Item> whiteListItem) { this.context = context1; this.ListItem = whiteListItem; this.mInflater = LayoutInflater.from(context); } public int getCount() { if ((this.ListItem !=null) && (this.ListItem.size() > 0)) { return 3; } return 0; } public Object getItem(int paramInt) { if ((this.ListItem != null) && (this.ListItem.size() > 0)) return this.ListItem.get(paramInt); return null; } public long getItemID(int paramInt) { return 0L; } @OverrIDe public VIEw getVIEw(int paramInt,VIEwGroup paramVIEwGroup) { Log.d("JGPS/MainActivity","getVIEw,position=" + paramInt + ",name=" + ((Item)this.ListItem.get(paramInt)).getname() + ",num=" + ((Item)this.ListItem.get(paramInt)).getNumber()); if (paramVIEw == null) { final VIEwHolder localVIEwHolder = new VIEwHolder(); paramVIEw = this.mInflater.inflate(R.layout.relative_List_item,null); localVIEwHolder.ivCall = (ImageVIEw)paramVIEw.findVIEwByID(R.ID.imageVIEw_call); localVIEwHolder.ivDelete = (ImageVIEw)paramVIEw.findVIEwByID(R.ID.imageVIEw_delete); localVIEwHolder.ivSelect = (ImageVIEw)paramVIEw.findVIEwByID(R.ID.recipIEnts_picker); localVIEwHolder.txtVIEw_name = (TextVIEw)paramVIEw.findVIEwByID(R.ID.txtVIEw_name); localVIEwHolder.txtVIEw_tel = (TextVIEw)paramVIEw.findVIEwByID(R.ID.txtVIEw_number); paramVIEw.setTag(localVIEwHolder); localVIEwHolder.position = paramInt; localVIEwHolder.ivSelect.setTag(localVIEwHolder); if ((this.ListItem.get(paramInt)== null)|| (((Item)this.ListItem.get(paramInt)).getNumber() == null) || (((Item)this.ListItem.get(paramInt)).getNumber().equals(""))) { localVIEwHolder.ivCall.setVisibility(VIEw.GONE); localVIEwHolder.ivSelect.setVisibility(VIEw.VISIBLE); String str1 = MainActivity.this.getString(R.string.family_string); String str2 = str1 + (paramInt + 1) + ":"; localVIEwHolder.txtVIEw_name.setText(str2); localVIEwHolder.txtVIEw_tel.setText(R.string.click_to_add); }else { localVIEwHolder.ivCall.setVisibility(VIEw.VISIBLE); localVIEwHolder.ivSelect.setVisibility(VIEw.GONE); localVIEwHolder.txtVIEw_name.setText(((Item)this.ListItem.get(paramInt)).getname()); localVIEwHolder.txtVIEw_tel.setText(((Item)this.ListItem.get(paramInt)).getNumber()); } localVIEwHolder.ivSelect.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { MainActivity.Whitelistadapter.VIEwHolder localVIEwHolder = (MainActivity.Whitelistadapter.VIEwHolder)paramVIEw.getTag(); Log.d("JGPS/MainActivity",mposition=" + MainActivity.this.mposition); MainActivity.this.startContactIntent(localVIEwHolder.position); } }); if ((!(((Item)this.ListItem.get(paramInt)).getname().equals(""))) || (!(((Item)this.ListItem.get(paramInt)).getNumber().equals("")))) { localVIEwHolder.ivDelete.setVisibility(VIEw.VISIBLE); }else { localVIEwHolder.ivDelete.setVisibility(VIEw.GONE); } localVIEwHolder.ivCall.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { Intent localintent = new Intent("androID.intent.action.CALL",Uri.parse("tel:" + ((Item)MainActivity.Whitelistadapter.this.ListItem.get(localVIEwHolder.position)).getNumber())); MainActivity.Whitelistadapter.this.context.startActivity(localintent); } }); localVIEwHolder.ivDelete.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { if(paramVIEw.getID() != R.ID.imageVIEw_delete) return; final String str = ((Item)MainActivity.Whitelistadapter.this.ListItem.get(localVIEwHolder.position)).getID(); Log.d("JGPS/MainActivity","delete item onClick,strID=" + str + ",position=" + localVIEwHolder.position); final Dialog localDialog = new Dialog(MainActivity.Whitelistadapter.this.context,R.style.dialog); localDialog.show(); Window localWindow = localDialog.getwindow(); localWindow.setContentVIEw(R.layout.dialog_delete); ((TextVIEw)localWindow.findVIEwByID(R.ID.txtVIEw_delete)).setText(MainActivity.Whitelistadapter.this.context.getResources().getString(R.string.delete_one) + "'" + ((Item)MainActivity.Whitelistadapter.this.ListItem.get(localVIEwHolder.position)).getname() + "'" + MainActivity.Whitelistadapter.this.context.getResources().getString(R.string.delete_two)); button localbutton1 = (button) localWindow.findVIEwByID(R.ID.btn_ok); button localbutton2 = (button) localWindow.findVIEwByID(R.ID.btn_cancel); localbutton1.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { MainActivity.this.deleteContactFromDB(str); localDialog.cancel(); } }); localbutton2.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw paramVIEw) { localDialog.cancel(); } }); } }); }else { } return paramVIEw; } public class VIEwHolder{ public ImageVIEw ivCall; public ImageVIEw ivDelete; public ImageVIEw ivSelect; public int position; public TextVIEw txtVIEw_name; public TextVIEw txtVIEw_tel; }}}import java.util.ArrayList;import androID.content.ContentValues;import androID.content.Context;import androID.database.Cursor;import androID.database.sqlite.sqliteDatabase;import androID.database.sqlite.sqliteOpenHelper;import androID.util.Log;public class DBHelper extends sqliteOpenHelper {public static final String table_relativeS_CONTENT = "relativesContent";public static final int VERSION = 1; //版本public static final String dbname = "SosDB"; //数据库的名字public static Context mContext = null;public sqliteDatabase db = null;public DBHelper(Context paramContext) { super(paramContext,"SosDB",null,1); mContext = paramContext;}// 创建数据库表@OverrIDepublic voID onCreate(sqliteDatabase paramsqliteDatabase) { paramsqliteDatabase.execsql("create table relativesContent(ID integer primary key autoincrement,name text,number text)"); closeDatabase();}private voID closeDatabase() { if (this.db == null) return; this.db.close();}@OverrIDepublic voID onUpgrade(sqliteDatabase paramsqliteDatabase,int paramInt1,int paramInt2) { onCreate(paramsqliteDatabase);}//查询方法public ArrayList<Item> getrelativesList() { String IDf = null; String namef = null; String numf = null; ArrayList localArrayList = new ArrayList(); openDatabase(); Cursor localCursor = this.db.query("relativesContent",null); if(localCursor == null) return localArrayList; while (localCursor.movetoNext()) { Item localitem = new Item(); IDf = localCursor.getString(localCursor.getColumnIndex("ID")); namef = localCursor.getString(localCursor.getColumnIndex("name")); numf = localCursor.getString(localCursor.getColumnIndex("number")); localitem.setID(IDf); Log.d("JGPS/MainActivity","dbID=" + IDf); if ((namef == null) || ("".equals(namef))) { localitem.setname(""); }else { localitem.setname(namef); } if ((numf == null) || ("".equals(numf))) { localitem.setNumber(""); }else { localitem.setNumber(numf); } localArrayList.add(localitem); } return localArrayList;}//写入数据private voID openDatabase() { this.db = super.getWritableDatabase();}//添加数据public boolean addrelativesItem(Item localitem) { openDatabase(); ContentValues localContentValues = new ContentValues(); localContentValues.put("name",localitem.getname()); localContentValues.put("number",localitem.getNumber()); long l = this.db.insert("relativesContent",localContentValues); closeDatabase(); return (1<=0L);}//更新数据public boolean updaterelativesItem(Item paramItem) { openDatabase(); ContentValues localContentValues = new ContentValues(); localContentValues.put("name",paramItem.getname()); localContentValues.put("number",paramItem.getNumber()); sqliteDatabase localsqliteDatabase = this.db; String[] arrayofstring = new String[1]; arrayofstring[0] = paramItem.getID(); long l = localsqliteDatabase.update("relativesContent",localContentValues,"ID=?",arrayofstring); closeDatabase(); return (1 <= 0L);}}import java.io.Serializable;public class Item implements Serializable{private String _ID;private String name;private String number;public Item() { // Todo auto-generated constructor stub}public voID Item(String paramString1,String paramString3) { this._ID = paramString1; this.name = paramString2; this.number = paramString3; }public String getID() { return _ID;}public voID setID(String paramString) { this._ID = paramString; }public String getname() { return name;}public voID setname(String paramString) { this.name = paramString; }public String getNumber() { return number;}public voID setNumber(String paramString) { this.number = paramString; } }这是基本的数据程序。
XML
relative_main
@H_404_26@<linearLayout androID:orIEntation="vertical" androID:background="@color/background_color" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"xmlns:androID="http://schemas.androID.com/apk/res/androID"><relativeLayout androID:background="@drawable/Title_bar" androID:layout_wIDth="fill_parent" androID:layout_height="50.0sp"> <TextVIEw androID:textSize="@dimen/Title_size" androID:textStyle="bold" androID:textcolor="@color/Title_color" androID:gravity="center" androID:layout_gravity="center" androID:layout_wIDth="wrap_content" androID:layout_height="50.0sp" androID:text="@string/relative_name" androID:layout_centerInParent="true" /></relativeLayout><relativeLayout androID:ID="@+ID/white_content" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content"> <ListVIEw androID:ID="@+ID/List_vIEw" androID:scrollbars="none" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:scrollingCache="true" androID:cachecolorHint="#00000000" androID:divIDer="@null" androID:fastScrollEnabled="false" /></relativeLayout></linearLayout>dialog_editor<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:gravity="center" androID:orIEntation="vertical" androID:ID="@+ID/linearlayout_dialog" androID:layout_wIDth="300.0dip" androID:layout_height="wrap_content"> <TextVIEw androID:textSize="20.0sp" androID:textcolor="#ffffffff" androID:gravity="center" androID:ID="@+ID/Title" androID:background="@drawable/popup_topbg" androID:layout_wIDth="fill_parent" androID:layout_height="60.0dip" androID:text="@string/add_white" /><linearLayout androID:orIEntation="vertical" androID:background="@drawable/simple_dialog_List_item_bg" androID:paddingleft="5.0dip" androID:paddingtop="5.0dip" androID:paddingRight="5.0dip" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content"> <linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="8.0dip" androID:layout_margintop="6.0dip" androID:layout_marginRight="6.0dip" androID:layout_marginBottom="2.0dip"> <TextVIEw androID:textSize="16.0sp" androID:textcolor="#ff000000" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/name" /> <EditText androID:gravity="left|center" androID:ID="@+ID/name" androID:background="@drawable/text_input" androID:layout_wIDth="210.0dip" androID:layout_height="wrap_content" androID:layout_marginleft="8.0dip" androID:hint="@string/name_hint" androID:singleline="true" /> </linearLayout> <linearLayout androID:layout_gravity="center" androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_marginleft="8.0dip" androID:layout_marginRight="6.0dip"> <TextVIEw androID:textSize="16.0sp" androID:textcolor="#ff000000" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/address" /> <EditText androID:gravity="left|center" androID:ID="@+ID/phone" androID:background="@drawable/text_input" androID:layout_wIDth="210.0dip" androID:layout_height="wrap_content" androID:layout_marginleft="8.0dip" androID:hint="@string/address_hint" androID:singleline="true" androID:inputType="phone" /> </linearLayout> <include layout="@layout/divIDer" /> <linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="54.0dip"> <button androID:textSize="20.0sp" androID:ID="@+ID/btn_ok" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:text="@string/ok" androID:layout_weight="5.0" /> <VIEw androID:background="#ffbcc2c5" androID:layout_wIDth="2.0px" androID:layout_height="fill_parent" /> <button androID:textSize="20.0sp" androID:ID="@+ID/btn_cancel" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:text="@string/cancel" androID:layout_weight="5.0" /> </linearLayout></linearLayout> </linearLayout>
relative_List_item
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:gravity="center_vertical" androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="40.0dip" ><linearLayout androID:gravity="center_vertical" androID:orIEntation="horizontal" androID:ID="@+ID/ll_line1" androID:paddingleft="5.0dip" androID:paddingRight="5.0dip" androID:layout_wIDth="0.0dip" androID:layout_height="wrap_content" androID:layout_weight="1.0"> <TextVIEw androID:textSize="@dimen/List_Font_size_0" androID:textStyle="bold" androID:textcolor="@color/List_item_text" androID:ellipsize="end" androID:gravity="center" androID:ID="@+ID/txtVIEw_name" androID:paddingBottom="3.0dip" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:maxWIDth="80.0dip" androID:singleline="true" /> <TextVIEw androID:textSize="@dimen/List_Font_size_1" androID:textStyle="bold" androID:textcolor="@color/List_item_text" androID:ellipsize="end" androID:gravity="center" androID:ID="@+ID/txtVIEw_number" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="10.0dip" androID:singleline="true" /></linearLayout><ImageVIEw androID:layout_gravity="center_vertical" androID:ID="@+ID/imageVIEw_call" androID:background="@drawable/btn_dial_action" androID:paddingleft="8.0dip" androID:paddingtop="8.0dip" androID:paddingRight="8.0dip" androID:paddingBottom="8.0dip" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/call_phone" />" <ImageVIEw androID:layout_gravity="center_vertical" androID:ID="@+ID/recipIEnts_picker" androID:background="@drawable/add_contact_selector" androID:layout_wIDth="65.0dip" androID:layout_height="65.0dip" androID:layout_marginleft="2.0dip" androID:layout_marginRight="2.0dip" androID:scaleType="fitXY" /><VIEw androID:ID="@+ID/imageVIEw_divIDer" androID:background="#2b2b2b2b" androID:layout_wIDth="2.0dip" androID:layout_height="40.0dip" /><ImageVIEw androID:layout_gravity="right|center" androID:ID="@+ID/imageVIEw_delete" androID:paddingleft="8.0dip" androID:paddingtop="8.0dip" androID:paddingRight="8.0dip" androID:paddingBottom="8.0dip" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/del_cross" /> </linearLayout>
dialog_delete
@H_404_26@<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:gravity="center" androID:orIEntation="vertical" androID:ID="@+ID/linearLayout_dialog" androID:layout_wIDth="300.0dip" androID:layout_height="wrap_content"><TextVIEw androID:textSize="20.0sp" androID:textcolor="#ffffffff" androID:gravity="center" androID:background="@drawable/popup_topbg" androID:layout_wIDth="fill_parent" androID:layout_height="60.0dip" androID:text="@string/tips" /><linearLayout androID:orIEntation="vertical" androID:background="@drawable/simple_dialog_List_item_bg" androID:paddingleft="5.0dip" androID:paddingtop="12.0dip" androID:paddingRight="5.0dip" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content"> <TextVIEw androID:textSize="20.0sp" androID:textcolor="#ff000000" androID:ID="@+ID/txtVIEw_delete" androID:paddingBottom="12.0dip" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="8.0dip" androID:layout_marginRight="6.0dip" /> <include layout="@layout/divIDer" /> <linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="54.0dip"> <button androID:textSize="20.0sp" androID:ID="@+ID/btn_ok" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:text="@string/dialog_yes" androID:layout_weight="5.0" /> <VIEw androID:background="#ffbcc2c5" androID:layout_wIDth="2.0px" androID:layout_height="fill_parent" /> <button androID:textSize="20.0sp" androID:ID="@+ID/btn_cancel" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:text="@string/dialog_no" androID:layout_weight="5.0" /> </linearLayout></linearLayout></linearLayout>
这是一个简单的demo,我这里就不详细说明数据库的细节了,对于已经很熟悉数据库的,可以查看androID官网有说明的,
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
总结以上是内存溢出为你收集整理的Android 中SQLite技术实例详解全部内容,希望文章能够帮你解决Android 中SQLite技术实例详解所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)