Android SQLite数据库创建和使用实战(一)

转载地址:http://blog.csdn.net/yanbober/article/details/20688273

废话不多说,Android撑死算个入门选手,刚好有点时间,随之倒腾整理下Android数据库操作。码农只需要代码和原理,理论从代码中自己感悟。小二,上代码,弄。

功能基本包含了数据库基本功能,至于运行后人机操作界面只是随便写了个布局方便测试而已。

com/jesse/dbasetest1/DbAdapter.java(用来管理数据库,简单的例子嘛,规范啥的就免了,重在说理)。

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. package com.jesse.dbasetest1;  
  2.   
  3. import android.content.ContentValues;  
  4. import android.content.Context;  
  5. import android.database.Cursor;  
  6. import android.database.sqlite.SQLiteDatabase;  
  7. import android.database.sqlite.SQLiteDatabase.CursorFactory;  
  8. import android.database.sqlite.SQLiteOpenHelper;  
  9. import android.util.Log;  
  10. /** 
  11.  * @author Jesse 
  12.  * just for myself learn android SQLite. 
  13.  */  
  14. public class DbAdapter {  
  15.     public static final String TAG = DbAdapter.class.getSimpleName();  
  16.     private Context mContext;  
  17.       
  18.     public static final String KEY_ID = "_id";  
  19.     public static final String KEY_NAME = "name";  
  20.     public static final String KEY_AGE = "age";  
  21.     public static final String KEY_SEX = "sex";  
  22.   
  23.     public static final String DBASE_NAME = "persons";  
  24.     public static final String DBASE_TABLE = "base_info_table";  
  25.     public static final int DBASE_VERSION = 1;  
  26.       
  27.     public static final String DBASE_CREATE = "create table base_info_table "  
  28.                                             + "(_id integer primary key autoincrement, "  
  29.                                             + "name text not null, "  
  30.                                             + "age text not null, "  
  31.                                             + "sex text not null);";  
  32.       
  33.     private DataBaseHelper mBaseHelper;  
  34.     private SQLiteDatabase mDb;  
  35.       
  36.     public DbAdapter(Context context)  
  37.     {  
  38.         this.mContext = context;  
  39.         mBaseHelper = new DataBaseHelper(mContext, DBASE_NAME, null, DBASE_VERSION);  
  40.     }  
  41.       
  42.     public DbAdapter openDbase()  
  43.     {  
  44.         mDb = mBaseHelper.getWritableDatabase();  
  45.         return this;  
  46.     }  
  47.       
  48.     public void closeDbase()  
  49.     {  
  50.         mBaseHelper.close();  
  51.     }  
  52.       
  53.     public long insertPersonInfo(PersonInfo person)  
  54.     {  
  55.         ContentValues initialValues = new ContentValues();  
  56.           
  57.         initialValues.put(KEY_NAME, person.name);  
  58.         initialValues.put(KEY_AGE, person.age);  
  59.         initialValues.put(KEY_SEX, person.sex);  
  60.           
  61.         return mDb.insert(DBASE_TABLE, null, initialValues);  
  62.     }  
  63.       
  64.     public boolean deletePersonInfo(long rowId)  
  65.     {  
  66.         return (mDb.delete(DBASE_TABLE, KEY_ID + "=" + rowId, null) > 0);  
  67.     }  
  68.       
  69.     public Cursor getAllPersonInfo()  
  70.     {  
  71.         return mDb.query(DBASE_TABLE, new String[]{KEY_ID,  
  72.                                                     KEY_NAME,  
  73.                                                     KEY_AGE,  
  74.                                                     KEY_SEX},   
  75.                                                     nullnullnullnullnull);  
  76.     }  
  77.       
  78.     public Cursor getPersonInfo(long rowId)  
  79.     {  
  80.         Cursor mCursor = mDb.query(DBASE_TABLE, new String[]{KEY_ID,  
  81.                                                     KEY_NAME,  
  82.                                                     KEY_AGE,  
  83.                                                     KEY_SEX},   
  84.                                                     KEY_ID + "=" + rowId,  
  85.                                                     nullnullnullnull);  
  86.         if (null != mCursor)  
  87.         {  
  88.             mCursor.moveToFirst();  
  89.         }  
  90.           
  91.         return mCursor;  
  92.     }  
  93.       
  94.     public boolean updatePersonInfo(long rowId, PersonInfo person)  
  95.     {  
  96.         ContentValues initialValues = new ContentValues();  
  97.           
  98.         initialValues.put(KEY_NAME, person.name);  
  99.         initialValues.put(KEY_AGE, person.age);  
  100.         initialValues.put(KEY_SEX, person.sex);  
  101.           
  102.         return (mDb.update(DBASE_TABLE, initialValues, KEY_ID + "=" + rowId, null) > 0);  
  103.     }  
  104.     //-----------------------------------------------------------------  
  105.     private class DataBaseHelper extends SQLiteOpenHelper{  
  106.   
  107.         public DataBaseHelper(Context context, String name,  
  108.                 CursorFactory factory, int version)   
  109.         {  
  110.             super(context, name, factory, version);  
  111.             // TODO Auto-generated constructor stub  
  112.         }  
  113.   
  114.         @Override  
  115.         public void onCreate(SQLiteDatabase db) {  
  116.             // TODO Auto-generated method stub  
  117.             db.execSQL(DBASE_CREATE);  
  118.         }  
  119.   
  120.         @Override  
  121.         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {  
  122.             // TODO Auto-generated method stub  
  123.             Log.w(TAG, "Upgrading database from version " + oldVersion  
  124.                     + " to " + newVersion + ", which will destroy all old data");  
  125.               
  126.             db.execSQL("DROP TABLE IF EXISTS titles");  
  127.             onCreate(db);  
  128.         }  
  129.     }  
  130. }  
com/jesse/dbasetest1/MainActivity.java(不解释,看不懂说明Android比我还次,哈哈)。

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. package com.jesse.dbasetest1;  
  2.   
  3. import android.os.Bundle;  
  4. import android.app.Activity;  
  5. import android.content.Context;  
  6. import android.database.Cursor;  
  7. import android.view.View;  
  8. import android.view.View.OnClickListener;  
  9. import android.widget.Button;  
  10. import android.widget.EditText;  
  11. import android.widget.TextView;  
  12. import android.widget.Toast;  
  13.   
  14. public class MainActivity extends Activity {  
  15.     private Context mContext;  
  16.     private EditText mNameEdTxt;  
  17.     private EditText mAgeEdTxt;  
  18.     private EditText mSexEdTxt;  
  19.     private Button mAddBtn;  
  20.       
  21.     private EditText mRmIdEdTxt;  
  22.     private Button mRemoveBtn;  
  23.       
  24.     private EditText mPersonIdEdTxt;  
  25.     private TextView mOneText;  
  26.     private Button mGetOneBtn;  
  27.   
  28.     private EditText mIdUpEdTxt;  
  29.     private EditText mNameUpEdTxt;  
  30.     private EditText mAgeUpEdTxt;  
  31.     private EditText mSexUpEdTxt;  
  32.     private Button mUpBtn;  
  33.       
  34.     private TextView mAllText;  
  35.     private Button mGetAllBtn;  
  36.       
  37.     private DbAdapter mDbAdapter;  
  38.       
  39.     @Override  
  40.     protected void onCreate(Bundle savedInstanceState) {  
  41.         super.onCreate(savedInstanceState);  
  42.         setContentView(R.layout.activity_main);  
  43.           
  44.         initData();  
  45.     }  
  46.       
  47.     private void initData()  
  48.     {  
  49.         mContext = MainActivity.this;  
  50.           
  51.         mNameEdTxt = (EditText) this.findViewById(R.id.person_name);  
  52.         mAgeEdTxt = (EditText) this.findViewById(R.id.person_age);  
  53.         mSexEdTxt = (EditText) this.findViewById(R.id.person_sex);  
  54.         mAddBtn = (Button) this.findViewById(R.id.add_btn);  
  55.           
  56.         mRmIdEdTxt = (EditText) this.findViewById(R.id.person_id);  
  57.         mRemoveBtn = (Button) this.findViewById(R.id.remove_btn);  
  58.           
  59.         mPersonIdEdTxt = (EditText) this.findViewById(R.id.get_person_id);  
  60.         mOneText = (TextView) this.findViewById(R.id.one_person_info);  
  61.         mGetOneBtn = (Button) this.findViewById(R.id.get_one_btn);  
  62.           
  63.         mIdUpEdTxt = (EditText) this.findViewById(R.id.id_up);   
  64.         mNameUpEdTxt = (EditText) this.findViewById(R.id.person_name_up);  
  65.         mAgeUpEdTxt = (EditText) this.findViewById(R.id.person_age_up);  
  66.         mSexUpEdTxt = (EditText) this.findViewById(R.id.person_sex_up);  
  67.         mUpBtn = (Button) this.findViewById(R.id.update_btn);  
  68.           
  69.         mAllText = (TextView) this.findViewById(R.id.all_person_info);  
  70.         mGetAllBtn = (Button) this.findViewById(R.id.get_all_btn);  
  71.           
  72.         mAddBtn.setOnClickListener(addBtnClickListener);  
  73.         mRemoveBtn.setOnClickListener(removeBtnClickListener);  
  74.         mGetOneBtn.setOnClickListener(getOneBtnClickListener);  
  75.         mUpBtn.setOnClickListener(upBtnClickListener);  
  76.         mGetAllBtn.setOnClickListener(getAllBtnClickListener);  
  77.           
  78.         mDbAdapter = new DbAdapter(mContext);  
  79.         mDbAdapter.openDbase();  
  80.     }  
  81.       
  82.     OnClickListener addBtnClickListener = new OnClickListener() {  
  83.         @Override  
  84.         public void onClick(View v) {  
  85.             // TODO Auto-generated method stub  
  86.             PersonInfo tempPerson = new PersonInfo();  
  87.             tempPerson.name = mNameEdTxt.getText().toString();  
  88.             tempPerson.age = mAgeEdTxt.getText().toString();  
  89.             tempPerson.sex = mSexEdTxt.getText().toString();  
  90.               
  91.             if ((mNameEdTxt.getText()!=null)&&(mAgeEdTxt.getText()!=null)&&(mSexEdTxt.getText()!=null))  
  92.             {  
  93.                 if (mDbAdapter.insertPersonInfo(tempPerson) >= 0)  
  94.                 {  
  95.                     Toast.makeText(mContext, "Add data to dbase successfull!", Toast.LENGTH_LONG).show();  
  96.                 }  
  97.             }  
  98.             else  
  99.             {  
  100.                 Toast.makeText(mContext, "Please resure your input data is full ok?", Toast.LENGTH_LONG).show();  
  101.             }  
  102.         }  
  103.     };  
  104.       
  105.     OnClickListener removeBtnClickListener = new OnClickListener() {  
  106.         @Override  
  107.         public void onClick(View v) {  
  108.             // TODO Auto-generated method stub  
  109.             if (mRmIdEdTxt.getText()!=null)  
  110.             {  
  111.                 if (mDbAdapter.deletePersonInfo(Integer.parseInt(mRmIdEdTxt.getText().toString())) == true)  
  112.                 {  
  113.                     Toast.makeText(mContext, "Remove data from dbase successfull!", Toast.LENGTH_LONG).show();  
  114.                 }  
  115.                 else  
  116.                 {  
  117.                     Toast.makeText(mContext, "Remove data from dbase failed!", Toast.LENGTH_LONG).show();  
  118.                 }  
  119.             }  
  120.             else  
  121.             {  
  122.                 Toast.makeText(mContext, "Please resure your input id is full ok?", Toast.LENGTH_LONG).show();  
  123.             }  
  124.         }  
  125.     };  
  126.       
  127.     OnClickListener getOneBtnClickListener = new OnClickListener() {  
  128.         @Override  
  129.         public void onClick(View v) {  
  130.             // TODO Auto-generated method stub  
  131.             if (mPersonIdEdTxt.getText()!=null)  
  132.             {  
  133.                 int idInPut = Integer.parseInt(mPersonIdEdTxt.getText().toString());  
  134.                 Cursor cursor = mDbAdapter.getPersonInfo(idInPut);  
  135.                 if (cursor.moveToFirst() == true)  
  136.                 {  
  137.                     PersonInfo personInfo = new PersonInfo();  
  138.                     String id = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_ID));  
  139.                     personInfo.name = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_NAME));  
  140.                     personInfo.age = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_AGE));  
  141.                     personInfo.sex = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_SEX));  
  142.                       
  143.                     cursor.close();  
  144.                     String str = "No:"+id+",name:"+personInfo.name+",age:"+personInfo.age+",sex:"+personInfo.sex;  
  145.                     mOneText.setText(str);  
  146.                 }  
  147.                 else  
  148.                 {  
  149.                     Toast.makeText(mContext, "Get One data from dbase failed!", Toast.LENGTH_LONG).show();  
  150.                 }  
  151.             }  
  152.             else  
  153.             {  
  154.                 Toast.makeText(mContext, "Please resure your input id is full ok?", Toast.LENGTH_LONG).show();  
  155.             }  
  156.         }  
  157.     };  
  158.       
  159.     OnClickListener upBtnClickListener = new OnClickListener() {  
  160.         @Override  
  161.         public void onClick(View v) {  
  162.             // TODO Auto-generated method stub  
  163.             PersonInfo tempPerson = new PersonInfo();  
  164.             tempPerson.name = mNameUpEdTxt.getText().toString();  
  165.             tempPerson.age = mAgeUpEdTxt.getText().toString();  
  166.             tempPerson.sex = mSexUpEdTxt.getText().toString();  
  167.               
  168.             if (mDbAdapter.updatePersonInfo(Integer.parseInt(mIdUpEdTxt.getText().toString()), tempPerson) == true)  
  169.             {  
  170.                 Toast.makeText(mContext, "Update data to dbase successfull!", Toast.LENGTH_LONG).show();  
  171.             }  
  172.             else  
  173.             {  
  174.                 Toast.makeText(mContext, "Update data to dbase falied!", Toast.LENGTH_LONG).show();  
  175.             }  
  176.         }  
  177.     };  
  178.       
  179.     OnClickListener getAllBtnClickListener = new OnClickListener() {  
  180.         @Override  
  181.         public void onClick(View v) {  
  182.             // TODO Auto-generated method stub  
  183.             Cursor cursor = mDbAdapter.getAllPersonInfo();  
  184.             if (cursor.moveToFirst() == true)  
  185.             {  
  186.                 String str = "";  
  187.                   
  188.                 for (int index=0; index<cursor.getCount(); index++)  
  189.                 {  
  190.                     PersonInfo temp = new PersonInfo();  
  191.                     String id = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_ID));  
  192.                     temp.name = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_NAME));  
  193.                     temp.age = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_AGE));  
  194.                     temp.sex = cursor.getString(cursor.getColumnIndex(DbAdapter.KEY_SEX));  
  195.                       
  196.                     str = str + "No:"+id+",name:"+temp.name+",age:"+temp.age+",sex:"+temp.sex + "\n";  
  197.                     cursor.moveToNext();  
  198.                 }  
  199.                 cursor.close();  
  200.                   
  201.                 mAllText.setText(str);  
  202.             }  
  203.             else  
  204.             {  
  205.                 Toast.makeText(mContext, "Get All data from dbase failed!", Toast.LENGTH_LONG).show();  
  206.             }  
  207.         }  
  208.     };  
  209.       
  210.     @Override  
  211.     protected void onDestroy() {  
  212.         // TODO Auto-generated method stub  
  213.         super.onDestroy();  
  214.         mDbAdapter.closeDbase();  
  215.     }  
  216. }  
main_activity_layout.xml(不解释,看不懂说明Android比我还次,哈哈)。

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="@drawable/bg"  
  6.     android:gravity="center"  
  7.     android:orientation="vertical"  
  8.     tools:context=".MainActivity" >  
  9.   
  10.     <TextView  
  11.         android:id="@+id/title"  
  12.         android:layout_width="wrap_content"  
  13.         android:layout_height="wrap_content"  
  14.         android:text="Jesse Android SQLite Person Info"  
  15.         android:textColor="@android:color/holo_red_light"  
  16.         android:textSize="30sp" />  
  17.   
  18.     <TextView  
  19.         android:layout_width="wrap_content"  
  20.         android:layout_height="wrap_content"  
  21.         android:text="Sina微博昵称:工匠若水"  
  22.         android:textColor="@android:color/black"  
  23.         android:textSize="15sp" />  
  24.   
  25.     <LinearLayout  
  26.         android:layout_width="match_parent"  
  27.         android:layout_height="wrap_content"  
  28.         android:layout_marginLeft="100dp"  
  29.         android:layout_marginRight="100dp"  
  30.         android:layout_marginTop="10dp"  
  31.         android:orientation="horizontal" >  
  32.   
  33.         <EditText  
  34.             android:id="@+id/person_name"  
  35.             android:layout_width="0dp"  
  36.             android:layout_height="wrap_content"  
  37.             android:layout_weight="1"  
  38.             android:hint="name"  
  39.             android:inputType="text"  
  40.             android:singleLine="true"  
  41.             android:textColorHint="@android:color/darker_gray"  
  42.             android:textSize="20sp" />  
  43.   
  44.         <EditText  
  45.             android:id="@+id/person_age"  
  46.             android:layout_width="0dp"  
  47.             android:layout_height="wrap_content"  
  48.             android:layout_weight="1"  
  49.             android:hint="age"  
  50.             android:inputType="number"  
  51.             android:singleLine="true"  
  52.             android:textColorHint="@android:color/darker_gray"  
  53.             android:textSize="20sp" />  
  54.   
  55.         <EditText  
  56.             android:id="@+id/person_sex"  
  57.             android:layout_width="0dp"  
  58.             android:layout_height="wrap_content"  
  59.             android:layout_weight="1"  
  60.             android:hint="sex"  
  61.             android:inputType="text"  
  62.             android:singleLine="true"  
  63.             android:textColorHint="@android:color/darker_gray"  
  64.             android:textSize="20sp" />  
  65.   
  66.         <Button  
  67.             android:id="@+id/add_btn"  
  68.             android:layout_width="0dp"  
  69.             android:layout_height="wrap_content"  
  70.             android:layout_weight="1"  
  71.             android:text="Add"  
  72.             android:textColor="@android:color/holo_blue_dark"  
  73.             android:textSize="20sp" />  
  74.     </LinearLayout>  
  75.   
  76.     <LinearLayout  
  77.         android:layout_width="fill_parent"  
  78.         android:layout_height="wrap_content"  
  79.         android:layout_marginLeft="100dp"  
  80.         android:layout_marginRight="100dp"  
  81.         android:layout_marginTop="40dp"  
  82.         android:orientation="horizontal" >  
  83.   
  84.         <EditText  
  85.             android:id="@+id/person_id"  
  86.             android:layout_width="0dp"  
  87.             android:layout_height="wrap_content"  
  88.             android:layout_weight="1"  
  89.             android:hint="id"  
  90.             android:inputType="number"  
  91.             android:singleLine="true"  
  92.             android:textColorHint="@android:color/darker_gray"  
  93.             android:textSize="20sp" />  
  94.   
  95.         <TextView  
  96.             android:id="@+id/temp"  
  97.             android:layout_width="0dp"  
  98.             android:layout_height="wrap_content"  
  99.             android:layout_weight="2" />  
  100.   
  101.         <Button  
  102.             android:id="@+id/remove_btn"  
  103.             android:layout_width="0dp"  
  104.             android:layout_height="wrap_content"  
  105.             android:layout_weight="1"  
  106.             android:text="Remove"  
  107.             android:textColor="@android:color/holo_blue_dark"  
  108.             android:textSize="20sp" />  
  109.     </LinearLayout>  
  110.   
  111.     <LinearLayout  
  112.         android:layout_width="fill_parent"  
  113.         android:layout_height="wrap_content"  
  114.         android:layout_marginLeft="100dp"  
  115.         android:layout_marginRight="100dp"  
  116.         android:layout_marginTop="40dp"  
  117.         android:orientation="horizontal" >  
  118.   
  119.         <EditText  
  120.             android:id="@+id/get_person_id"  
  121.             android:layout_width="0dp"  
  122.             android:layout_height="wrap_content"  
  123.             android:layout_weight="1"  
  124.             android:hint="id"  
  125.             android:inputType="text"  
  126.             android:singleLine="true"  
  127.             android:textColorHint="@android:color/darker_gray"  
  128.             android:textSize="20sp" />  
  129.   
  130.         <TextView  
  131.             android:id="@+id/one_person_info"  
  132.             android:layout_width="0dp"  
  133.             android:layout_height="wrap_content"  
  134.             android:layout_weight="2"  
  135.             android:background="@android:color/white"  
  136.             android:text="wait get person info!"  
  137.             android:textSize="20sp" />  
  138.   
  139.         <Button  
  140.             android:id="@+id/get_one_btn"  
  141.             android:layout_width="0dp"  
  142.             android:layout_height="wrap_content"  
  143.             android:layout_weight="1"  
  144.             android:text="Get One"  
  145.             android:textColor="@android:color/holo_blue_dark"  
  146.             android:textSize="20sp" />  
  147.     </LinearLayout>  
  148.   
  149.     <LinearLayout  
  150.         android:layout_width="match_parent"  
  151.         android:layout_height="wrap_content"  
  152.         android:layout_marginLeft="100dp"  
  153.         android:layout_marginRight="100dp"  
  154.         android:layout_marginTop="40dp"  
  155.         android:orientation="horizontal" >  
  156.   
  157.         <EditText  
  158.             android:id="@+id/id_up"  
  159.             android:layout_width="0dp"  
  160.             android:layout_height="wrap_content"  
  161.             android:layout_weight="1"  
  162.             android:hint="id of update"  
  163.             android:inputType="text"  
  164.             android:singleLine="true"  
  165.             android:textColorHint="@android:color/darker_gray"  
  166.             android:textSize="20sp" />  
  167.   
  168.         <EditText  
  169.             android:id="@+id/person_name_up"  
  170.             android:layout_width="0dp"  
  171.             android:layout_height="wrap_content"  
  172.             android:layout_weight="1"  
  173.             android:hint="new name"  
  174.             android:inputType="text"  
  175.             android:singleLine="true"  
  176.             android:textColorHint="@android:color/darker_gray"  
  177.             android:textSize="20sp" />  
  178.   
  179.         <EditText  
  180.             android:id="@+id/person_age_up"  
  181.             android:layout_width="0dp"  
  182.             android:layout_height="wrap_content"  
  183.             android:layout_weight="1"  
  184.             android:hint="new age"  
  185.             android:inputType="number"  
  186.             android:singleLine="true"  
  187.             android:textColorHint="@android:color/darker_gray"  
  188.             android:textSize="20sp" />  
  189.   
  190.         <EditText  
  191.             android:id="@+id/person_sex_up"  
  192.             android:layout_width="0dp"  
  193.             android:layout_height="wrap_content"  
  194.             android:layout_weight="1"  
  195.             android:hint="new sex"  
  196.             android:inputType="text"  
  197.             android:singleLine="true"  
  198.             android:textColorHint="@android:color/darker_gray"  
  199.             android:textSize="20sp" />  
  200.   
  201.         <Button  
  202.             android:id="@+id/update_btn"  
  203.             android:layout_width="0dp"  
  204.             android:layout_height="wrap_content"  
  205.             android:layout_weight="1"  
  206.             android:text="Update"  
  207.             android:textColor="@android:color/holo_blue_dark"  
  208.             android:textSize="20sp" />  
  209.     </LinearLayout>  
  210.   
  211.     <LinearLayout  
  212.         android:layout_width="fill_parent"  
  213.         android:layout_height="wrap_content"  
  214.         android:layout_marginLeft="100dp"  
  215.         android:layout_marginRight="100dp"  
  216.         android:layout_marginTop="40dp"  
  217.         android:orientation="horizontal" >  
  218.   
  219.         <TextView  
  220.             android:id="@+id/all_person_info"  
  221.             android:layout_width="0dp"  
  222.             android:layout_height="150dp"  
  223.             android:layout_weight="3"  
  224.             android:background="@android:color/white"  
  225.             android:text="wait get all person info!"  
  226.             android:textSize="20sp" />  
  227.   
  228.         <Button  
  229.             android:id="@+id/get_all_btn"  
  230.             android:layout_width="0dp"  
  231.             android:layout_height="wrap_content"  
  232.             android:layout_weight="1"  
  233.             android:text="Get ALL"  
  234.             android:textColor="@android:color/holo_blue_dark"  
  235.             android:textSize="20sp" />  
  236.     </LinearLayout>  
  237.   
  238. </LinearLayout>  

好了,至于去哪找运行后的数据库文件和上哪用啥工具查看,自己想办法吧,不解释,你懂的,easy!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值