安卓课程设计报告

目录

 

1.需求分析

1.1 UML用户需求用例图

       1.2 用户用例分析说明

1.3 UML管理者需求用例图

           1.4 管理者用例分析说明

2.系统设计

  2.1 系统模块及功能图

       2.2 UML时序图

       2.3 UML类图

        2.4 UML模块关系图

         2.4 数据库设计

3.系统测试

   3.1 功能模块测试用例

        3.2  测试结果

4.系统实现

       4.1 核心模块界面及关键代码

5.技术说明

  5.1应用技术与主要代码

6.项目总结

 

一、需求分析

需求的编写是为了研究影院售票系统软件的开发途径和应用方法。同时它也是进行项目策划、概要设计和详细设计的基础,是维护人员进行内部维护,信息更新,验收和测试的依据。本需求的购票人是与影院售票系统软件开发有联系的决策人,开发组成人员,扶助开发者以及软件校验者!

1.1 UML用户需求用例

安卓课程设计报告

 

 

                                             顾客用例图

1.2 用户用例分析说明

1.简要说明:

 

本用例描述用户在影院系统查询电影与信息的过程

 

2.基本流:

1)购票者查看电影信息来确认电影的名字,封面,电影简介。

2)购票者查看自己的优惠券与优惠码。

3)购票者查看自己的订单与钱包。

4)购票者查看自己的商城、电影票、活动。

5)购票者在我的页面向客服中心投诉等

6)用户在设置里退出登录

 

3.备选流:无

4.特殊要求:无

5.前置条件:执行“登录”用例

6.扩展点:无

7.相关数据:电影信息

1.3 UML管理者需求用例图

安卓课程设计报告

 

 

1.4 管理人员用例分析说明  

1.简要说明

本用例描述管理人员管理电影院的过程

2.基本流:  

1.管理人员在数据服务器上管理电影信息(修改,添加,删除)

2.将管理人员所做的改动返回数据服务器            

3.系统保存管理人员所做改动,并备份原数据

3.备选流:无

4.特殊要求:无

5.前置条件:执行“登录”用例

6.扩展点:无

7.相关数据:电影信息

 

二、系统设计

2.1系统模块及功能图

安卓课程设计报告

 

 

                                                             总体系统模块图

 

2.2 UML时序图

安卓课程设计报告

 

 

2.3 UML类图

安卓课程设计报告

 

系统类图

 安卓课程设计报告

 

2.4 数据库设计

 安卓课程设计报告

 

安卓课程设计报告

 

 安卓课程设计报告

 

 

package com.example.film;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class DbDataBase extends SQLiteOpenHelper implements BaseColumns{
    static String DB_NAME = "itcase.db";
    static int DB_VERSION = 1;
    static String TABLE_NAME = "mysql";
    static  String _NAME = "name";
    static String _PHONE= "phone";

    public DbDataBase(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("create table "+TABLE_NAME+"("+_ID+" integer primary key autoincrement,"+_NAME+" text ,"+_PHONE+" text)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

    }

}

二、系统测试

3.1 功能测试用例

1、登录

· 使用合法的用户登录系统

· 系统是否允许多次非法的登录,是否有次数限制

· 使用已经登录的账号登录系统是否正确处理

· 用户名、口令(密码)错误或漏填时能否登陆

· 登陆后,页面中登录信息

 

2、忘记密码

 ·忘记密码按钮是否可用

·点击按钮后是否可以正常跳转页面

·发送短信是否可以正常调用

 

3、电影列表展示页面

1)页面能否正常跳转

2)电影信息能否正常展示

3)能否滑动查看

 

4、底部导航按钮

1)按钮是否可以点击

2)是否可以正确跳转页面

 

5、票夹

1)能否正常展示页面

2)能否使用数据库进行增删改查

3)增删改查按钮是否可行

4)能否正常运行

 

6、我的页面

1)我的订单页面跳转测试

2)我的钱包页面跳转测试

3)客服中心页面跳转测试

4)设置页面跳转测试

 

7、退出登录

1)能否正确运行退出按钮

2)能否正确退回登录页面

3.2 测试结果

1、登录

 安卓课程设计报告

 

 

2、忘记密码

 安卓课程设计报告

 

 

3、电影列表展示页面

 安卓课程设计报告

 

 

 

4、底部导航按钮

 安卓课程设计报告

 

 

5、票夹

 

 安卓课程设计报告

 

 

6、我的页面

 安卓课程设计报告

 

 

 

7、退出登录

 

 安卓课程设计报告

 

 

二、系统实现

核心模块界面关键代码

1)登录页面

 安卓课程设计报告

 

 

package com.example.film;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
    private Button but;//创建一个按钮对象,导入包
    private Button btn;
    private EditText et1;
    private EditText et2;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //对but进行实例化
        but=(Button)findViewById(R.id.button1);
        btn=(Button)findViewById(R.id.button2);
        //创建but的单击事件,参数要传匿名内部类
        et1=(EditText)findViewById(R.id.editText1);
        et2=(EditText)findViewById(R.id.editText2);
        but.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                //测试使用System.out.println("hello..........");
                //要成功进行跳转到intent这个对象
                //第一个参数是原来的类,出发站以.this结尾
                //第二个参数是要跳转的类,结束站以class结尾
                //Intent in=new Intent(MainActivity.this,SecActivity.class);
                //startActivity(in);
                String  username=et1.getText().toString();
                String  pwd=et2.getText().toString();
                if(username.equals("djp")&&pwd.equals("3692369")){
                    //密码确认
                    Intent in=new Intent(MainActivity.this,FilmActivity.class);
                    startActivity(in);}
            }

        });
        btn.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent in2=new Intent();//创建意图对象
    /* 打电话
            in2.setAction(Intent.ACTION_CALL);指定意图动作
            in2.setData(Uri.parse("tel:5556"));
            startActivity(in2);启动意图*/
                //发短信
                in2.setAction(Intent.ACTION_SENDTO);
                in2.setData(Uri.parse("smsto:10086"));
                in2.putExtra("sms_body", "password");
                startActivity(in2);//=MainActivity.this.startActivity(in2)


            }

        });
    }//onCreat.


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

2)退出登录

 安卓课程设计报告

 

 

 

package com.example.film;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Main9Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main9);
        Button btn11 = (Button) findViewById(R.id.btn11);
        btn11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(Main9Activity.this, MainActivity.class);
                startActivity(i);
            }
        });
    }
}

 

3)电影展示页面

 安卓课程设计报告

 

 

package com.example.film;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import com.example.film.adpter.FilmAdpter;
import com.example.film.entity.Film;

import java.util.ArrayList;
import java.util.List;

public class Main2Activity extends AppCompatActivity {
    private List<Film> consList = new ArrayList();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initData();
        Toast.makeText(this,consList.size()+"",0).show();

        FilmAdpter adapter = new FilmAdpter(Main2Activity.this, R.layout.list_item, consList);
        //获取ListView
        ListView listView = (ListView) findViewById(R.id.listView);
        //给ListView设置适配器
        listView.setAdapter(adapter);
    }

    private void initData(){
        Film yewen4 = new Film(1,"《叶问4》","该片讲述了因故来到美国唐人街的叶问,意外卷入一场当地军方*与华人武馆的纠纷,叶问挺身而出,向世界证明了中国功夫。", R.drawable.yewen);
        consList.add(yewen4);

}

}

 

4)首页

 安卓课程设计报告

 

 

public class FilmActivity extends AppCompatActivity {
    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Intent intent = null;
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    mTextMessage.setText(R.string.title_home);
                    return true;
                case R.id.navigation_dashboard:
                    mTextMessage.setText(R.string.title_dashboard);
                    intent = new Intent(FilmActivity.this,Main2Activity.class);
                    startActivity(intent);
                    return true;
                case R.id.navigation_piaojia:
                    mTextMessage.setText("票夹");
                    intent = new Intent(FilmActivity.this,Main5Activity.class);
                    startActivity(intent);
                    return true;

                    case R.id.navigation_notifications:
                    mTextMessage.setText(R.string.title_notifications);
                    intent = new Intent(FilmActivity.this,otherActivity.class);
                    startActivity(intent);
                    return true;
            }
            return false;
        }
    };

 

5)票夹

 

 安卓课程设计报告

 

 

public class Main5Activity extends Activity implements View.OnClickListener  {

    private ContactDao mContactDao;
    private Button mBtnadd;
    private Button mBtnupdata;
    private Button mBtnquery;
    private Button mBtndelete;
    private EditText mName;
    private EditText mPhone;
    private TextView mTv;
    private String name="";
    private String phone="";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContactDao = new ContactDao(this);
        init();
        mTv.setText(mContactDao.Select(name));

    }
    private void init() {
        mName = (EditText) findViewById(R.id.name);
        mPhone = (EditText) findViewById(R.id.phone);
        mBtnadd =(Button) findViewById(R.id.btn_add);
        mTv = (TextView) findViewById(R.id.tv);
        mBtnupdata =(Button) findViewById(R.id.btn_updata);
        mBtnquery =(Button) findViewById(R.id.btn_query);
        mBtndelete =(Button) findViewById(R.id.btn_delete);
        mBtnadd.setOnClickListener(this);
        mBtnupdata.setOnClickListener(this);
        mBtnquery.setOnClickListener(this);
        mBtndelete.setOnClickListener(this);
    }

 

6)我的页面

 安卓课程设计报告

 

 

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_other);
    Button btn5 = (Button) findViewById(R.id.btn5);
    Button btn6 = (Button) findViewById(R.id.btn6);
    Button btn7 = (Button) findViewById(R.id.btn7);
    Button btn8 = (Button) findViewById(R.id.btn8);
    btn5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(otherActivity.this, Main7Activity.class);
            startActivity(i);
        }
    });
    btn6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(otherActivity.this, Main4Activity.class);
            startActivity(i);
        }
    });
    btn7.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(otherActivity.this, Main8Activity.class);
            startActivity(i);
        }
    });

    btn8.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(otherActivity.this, Main9Activity.class);
            startActivity(i);
        }
    });

 

7)我的钱包

 安卓课程设计报告

 

 

<Button
    android:id="@+id/btn9"
    android:layout_width="0dp"
    android:layout_height="61dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="65dp"
    android:layout_marginRight="65dp"
    android:text="优惠券"
    app:layout_constraintEnd_toStartOf="@+id/btn10"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/imageView9"
    android:layout_width="414dp"
    android:layout_height="721dp"
    android:layout_marginStart="1dp"
    android:layout_marginLeft="1dp"
    android:layout_marginTop="15dp"
    android:layout_marginEnd="1dp"
    android:layout_marginRight="1dp"
    android:layout_marginBottom="15dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.545"
    app:srcCompat="@drawable/qian" />
<Button
    android:id="@+id/btn10"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:text="会员卡"
    app:layout_constraintBottom_toBottomOf="@id/btn9"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/btn9"
    app:layout_constraintTop_toTopOf="@+id/btn9" />

 

8)我的订单

 安卓课程设计报告

 

 

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main4);
    Button btn2 = (Button) findViewById(R.id.btn2);
    Button btn3 = (Button) findViewById(R.id.btn3);
    btn2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Main4Activity.this, Main3Activity.class);
            startActivity(i);
        }
    });
    btn3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Main4Activity.this, Main6Activity.class);
            startActivity(i);
        }
    });

 

 

9)客服中心

 安卓课程设计报告

 

 

<Button
    android:id="@+id/button"
    android:layout_width="match_parent"
    android:layout_height="91dp"
    android:text="顾客满意度调查" />

<Button
    android:id="@+id/button3"
    android:layout_width="match_parent"
    android:layout_height="78dp"
    android:text="智能客服" />

<Button
    android:id="@+id/button4"
    android:layout_width="match_parent"
    android:layout_height="82dp"
    android:text="投诉建议" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="match_parent"
    android:layout_height="38dp"
    android:text="  院线客服统一热线     400-080-6060"
    android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="match_parent"
    android:layout_height="41dp"
    android:text="  全国统一投诉热线     400-009-5066"
    android:textAppearance="@style/TextAppearance.AppCompat.Large" />

五.技术说明

1、UI设计

安卓课程设计报告

 

 

安卓课程设计报告

 

 安卓课程设计报告

 

 

安卓课程设计报告

 

 

 

 

 

 

主要代码:

package com.example.film;

import android.os.Bundle;
import android.content.Intent;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;

import android.view.MenuItem;
import android.widget.TextView;

public class FilmActivity extends AppCompatActivity {
    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Intent intent = null;
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    mTextMessage.setText(R.string.title_home);
                    return true;
                case R.id.navigation_dashboard:
                    mTextMessage.setText(R.string.title_dashboard);
                    intent = new Intent(FilmActivity.this,Main2Activity.class);
                    startActivity(intent);
                    return true;
                case R.id.navigation_piaojia:
                    mTextMessage.setText("票夹");
                    intent = new Intent(FilmActivity.this,Main5Activity.class);
                    startActivity(intent);
                    return true;

                    case R.id.navigation_notifications:
                    mTextMessage.setText(R.string.title_notifications);
                    intent = new Intent(FilmActivity.this,otherActivity.class);
                    startActivity(intent);
                    return true;
            }
            return false;
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_film);
        BottomNavigationView navView = findViewById(R.id.nav_view);
        mTextMessage = findViewById(R.id.message);
        navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    }

 

2Activity组件的应用

 

 安卓课程设计报告

 

 

主要代码

public class FilmActivity extends AppCompatActivity {
    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Intent intent = null;
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    mTextMessage.setText(R.string.title_home);
                    return true;
                case R.id.navigation_dashboard:
                    mTextMessage.setText(R.string.title_dashboard);
                    intent = new Intent(FilmActivity.this,Main2Activity.class);
                    startActivity(intent);
                    return true;
                case R.id.navigation_piaojia:
                    mTextMessage.setText("票夹");
                    intent = new Intent(FilmActivity.this,Main5Activity.class);
                    startActivity(intent);
                    return true;

                    case R.id.navigation_notifications:
                    mTextMessage.setText(R.string.title_notifications);
                    intent = new Intent(FilmActivity.this,otherActivity.class);
                    startActivity(intent);
                    return true;
            }
            return false;
        }
    };



3ListView的使用

 

 安卓课程设计报告

 

 

主要代码:

public class Main2Activity extends AppCompatActivity {
    private List<Film> consList = new ArrayList();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initData();
        Toast.makeText(this,consList.size()+"",0).show();

        FilmAdpter adapter = new FilmAdpter(Main2Activity.this, R.layout.list_item, consList);
        //获取ListView
        ListView listView = (ListView) findViewById(R.id.listView);
        //给ListView设置适配器
        listView.setAdapter(adapter);
    }

    private void initData(){
        Film yewen4 = new Film(1,"《叶问4》","该片讲述了因故来到美国唐人街的叶问,意外卷入一场当地军方*与华人武馆的纠纷,叶问挺身而出,向世界证明了中国功夫。", R.drawable.yewen);
        consList.add(yewen4);

}

}

 

 

4、ListView适配器的使用:

安卓课程设计报告

 

 

 

 

 

 

主要代码:

package com.example.film.adpter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.film.entity.Film;

import java.util.List;

import com.example.film.R;
public class FilmAdpter extends ArrayAdapter{
    private int resourceId;
    //参数1:当前Activity,参数2:layout文件的id,参数3:业务数据(List)
    public FilmAdpter(Context context, int resource, List objects) {
        super(context, resource, objects);
        resourceId = resource;
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //获取当前项的实体类对象
        Film cons= (Film) this.getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        //获取布局内的控件
        ImageView consImage = (ImageView)view.findViewById(R.id.itemImage);
        TextView consName = (TextView)view.findViewById(R.id.itemName);
        TextView content = (TextView)view.findViewById(R.id.itemContent);
        //为布局内的控件设置实体对象中的数据
        consImage.setImageResource(cons.getImgId());
        consName.setText(cons.getConName());
        content.setText(cons.getContent());
        //将适配好的ListView返回
        return view;
    }
}

 

2、File存储

主要代码:

private ContactDao mContactDao;
private Button mBtnadd;
private Button mBtnupdata;
private Button mBtnquery;
private Button mBtndelete;
private EditText mName;
private EditText mPhone;
private TextView mTv;
private String name="";
private String phone="";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContactDao = new ContactDao(this);
    init();
    mTv.setText(mContactDao.Select(name));

}
private void init() {
    mName = (EditText) findViewById(R.id.name);
    mPhone = (EditText) findViewById(R.id.phone);
    mBtnadd =(Button) findViewById(R.id.btn_add);
    mTv = (TextView) findViewById(R.id.tv);
    mBtnupdata =(Button) findViewById(R.id.btn_updata);
    mBtnquery =(Button) findViewById(R.id.btn_query);
    mBtndelete =(Button) findViewById(R.id.btn_delete);
    mBtnadd.setOnClickListener(this);
    mBtnupdata.setOnClickListener(this);
    mBtnquery.setOnClickListener(this);
    mBtndelete.setOnClickListener(this);
}

 

static String DB_NAME = "itcase.db";
static int DB_VERSION = 1;
static String TABLE_NAME = "mysql";
static  String _NAME = "name";
static String _PHONE= "phone";

public DbDataBase(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
    // TODO Auto-generated constructor stub
}

@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL("create table "+TABLE_NAME+"("+_ID+" integer primary key autoincrement,"+_NAME+" text ,"+_PHONE+" text)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub

 

3、SQLite数据库

 安卓课程设计报告

 

 

 

 

主要代码:

 

package com.example.film;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class ContactDao {

    private static DbDataBase mDbDataBase;

    public ContactDao(Context c){
        mDbDataBase = new DbDataBase(c);
    }
    public static boolean Insert(String name ,String phone) {
        SQLiteDatabase db = mDbDataBase.getWritableDatabase();
//       db.insert(table, nullColumnHack, values) 三个参数 分别是表名 返回的是一个 插入字段的id 但插入错误的时候 返回的时候-1
//         nullColumnHack 比如 放了 username 那么usename 就不得为空 如果为空 那么就有字段可以为空
//          valuse 是一个     ContentValues values = new ContentValues(); 一个对象 向里面填要填加的数据
        ContentValues values = new ContentValues();
        values.put(DbDataBase._NAME, name);
        values.put(DbDataBase._PHONE, phone);
        long InsertId = db.insert(DbDataBase.TABLE_NAME, null, values);
        return InsertId!=-1;
    }
    public static boolean Updata(String name,String phone) {
        SQLiteDatabase db = mDbDataBase.getWritableDatabase();
//      db.update(table, values, whereClause, whereArgs); 四个参数  前两个同上 返回的是修改的那条数据的id 要是修改出错是 id=0
//         后两个whereClause 是sql语句中的where 语句   whereArgs是 where语句绑定值 where语句绑定值 new String[]{username}
        ContentValues values = new ContentValues();
        values.put(DbDataBase._PHONE, phone);
        int Uqdata =db.update(DbDataBase.TABLE_NAME, values, DbDataBase._NAME+"=?",  new String[]{name});
        return Uqdata>0;
    }
    public static boolean Delete(String name) {
        SQLiteDatabase db = mDbDataBase.getWritableDatabase();
//      db.delete(table, whereClause, whereArgs) 三个参数 同上; 返回的是删除的那个id 要是删除出错 返回 0
        int DeleteID =db.delete(DbDataBase.TABLE_NAME, DbDataBase._NAME+"=?", new String[]{name});
        return DeleteID>0;
    }
    public static String Select (String name) {
        SQLiteDatabase db=mDbDataBase.getReadableDatabase();
//      db.query(table, columns, selection, selectionArgs, null, null, null); 后三参数个为空
//         第一个是表名 第二个是 返回的数据 第三个 查询条件  第四个是查询条件的值
        Cursor cusor = null;
        String text ="";

        cusor = db.query(DbDataBase.TABLE_NAME, null, null, null, null, null, null);

//          cusor = db.query(DbDataBase.TABLE_NAME, new String[] {DbDataBase._NAME,DbDataBase._PHONE},
//                  DbDataBase._NAME+"=?",new String[]{name}, null, null, null);

        while (cusor.moveToNext()){
            int nameIntdex = cusor.getColumnIndex(DbDataBase._NAME);
            text+=("name: "+cusor.getString(nameIntdex)+"\n");
            int phoneIndex = cusor.getColumnIndex(DbDataBase._PHONE);
            text+=("phone: "+cusor.getString(phoneIndex)+"\n");
        }
        return text;


    }

 

 

public class DbDataBase extends SQLiteOpenHelper implements BaseColumns{

    static String DB_NAME = "itcase.db";
    static int DB_VERSION = 1;
    static String TABLE_NAME = "mysql";
    static  String _NAME = "name";
    static String _PHONE= "phone";

    public DbDataBase(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("create table "+TABLE_NAME+"("+_ID+" integer primary key autoincrement,"+_NAME+" text ,"+_PHONE+" text)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

    }

}

 

 

 .项目总结

课程设计的过程中,我遇到了很多问题,通过查阅参考书和的指导,都得到了解决。这不仅仅锻炼了我分析问题和解决问题的能力,也使我意识到自己对知识的了解程度远了,知识的缺乏也在很多方面。以后我一定会努力提高自己的理论水平,同时尽可能多地读一些科学书籍,提高自己的理论水平和动手实践能力。由于时间的限制,解决这个问题和本文不能被称为完美。在许多地方还有待阐述,修改和完善

 

 

附录:

一、清单文件

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.film">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Main2Activity"></activity>
        <activity android:name=".Main10Activity" />
        <activity android:name=".Main9Activity" />
        <activity android:name=".Main8Activity" />
        <activity android:name=".Main7Activity" />
        <activity android:name=".Main5Activity" />
        <activity android:name=".Main6Activity" />
        <activity android:name=".Main4Activity" />
        <activity android:name=".Main3Activity" />
        <activity
            android:name=".FilmActivity"
            android:label="@string/title_activity_film" />
        <activity android:name=".otherActivity" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

、布局文件目录

 安卓课程设计报告

 

 

 

 

 

 

 

 

 

安卓课程设计报告

上一篇:java web程序 html标签中和的用法区别:


下一篇:一篇文章搞懂android存储目录结构