1Android学生信息管理系统APP一、需求分析为了方便的进行对学生数据库的操作,本app可在android设备上进行对学生信息数据库的信息管理功能,具体功能如下:1.对数据库中所有学生姓名进行显示,对各个条目进行点击可展开具体信息2.查询数据:查询数据是根据姓名与学号两个条件进行查询,两者满足任一条件则进行模糊查询,两个条件同时满足则进行精确查询,查询结果界面与功能一中相同,以姓名排列,点击展开所有信息3.增加数据:在数据库中增添条目,包括姓名(字符串),学号(数字,主键),性别(单选框),年龄(数字),专业(字符串)。每个条目均有误输入设定,且主键可检查重复性,所有数据可检查完整性,若插入成功则会显示一条消息提示成功,若失败则会提示检查主键重复或者数据不完整4.修改数据:根据姓名学号进行精确查找,查找成功后转入修改界面,为了防止漏填与便捷修改界面会默认填充之前的数据(除学号),修改完毕即可更新,同样会检查数据完整性25.删除数据:根据姓名学号进行精确查找,查找成功则会进行删除,并显示一条删除成功的提示,若失败,也会进行提示二、概念结构设计ER图:三、逻辑结构设计学生:姓名(字符串)学号(数字,主码)3性别(单选框)年龄(数字)专业(字符串)createtablestudent(nameTEXT,NOTEXTPrimaryKey,sexTEXT,professionTEXT,ageTEXT)四、具体实现1.主界面:4主界面显示所有功能,每个按钮点击后,跳转进入相应功能核心代码:publicclassMainextendsActivity{SQLiteDatabasedb;Buttonbtn_search;Buttonbtn_modify;Buttonbtn_add;Buttonbtn_delete;Buttonbtn_quit;Buttonbtn_show;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentView(R.layout.layout_main);//打开数据库,若不存在,则创建db=SQLiteDatabase.openOrCreateDatabase(this.getFilesDir().toString()+/Student.db3,null);btn_search=(Button)findViewById(R.id.btn_search);btn_modify=(Button)findViewById(R.id.btn_modify);btn_add=(Button)findViewById(R.id.btn_add);btn_delete=(Button)findViewById(R.id.btn_delete);btn_quit=(Button)findViewById(R.id.btn_quit);btn_show=(Button)findViewById(R.id.Btn_show);try{Cursorcursor=db.rawQuery(select*fromstudent,null);cursor.close();}catch(SQLiteExceptione){5db.execSQL(createtablestudent+(+nameTEXT,+NOTEXTPrimaryKey,+sexTEXT,+professionTEXT,+ageTEXT+));}//显示所有数据按钮的功能实现btn_show.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){//获取指针Cursorcursor=db.rawQuery(select*fromstudent,null);//判断数据库是否不存在任何数据if(cursor.moveToFirst()==false){Toast.makeText(Main.this,不存在记录,Toast.LENGTH_SHORT).show();}else{ListStudentp=newArrayListStudent();ListStringre_name=newArrayListString();ListString[]info=newArrayListString[]();//保存搜索出的所有数据for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()){intnameColume=cursor.getColumnIndex(name);intNOColume=cursor.getColumnIndex(NO);intproColume=cursor.getColumnIndex(profession);intsexColume=cursor.getColumnIndex(sex);intageColume=cursor.getColumnIndex(age);Studentstudent=newStudent();student.name=姓名:+cursor.getString(nameColume);student.NO=学号:+cursor.getString(NOColume);student.sex=性别:+cursor.getString(sexColume);6student.profession=专业:+cursor.getString(proColume);student.age=年龄:+cursor.getString(ageColume);p.add(student);String[]temp=student.MakeString();info.add(temp);Stringnewname=cursor.getString(nameColume);re_name.add(newname);}//对保存的数据进行封装String[]Cur_name=newString[re_name.size()];Cur_name=re_name.toArray(Cur_name);String[][]Cur_info=newString[info.size()][];Cur_info=info.toArray(Cur_info);Bundlebundle=newBundle();bundle.putStringArray(name,Cur_name);Studentdata=newStudent();data.info=Cur_info;//将封装的数据传递给结果界面的activityIntentintent=newIntent(Main.this,SearchResult.class);intent.putExtras(bundle);intent.putExtra(data,data);startActivity(intent);cursor.close();}}});//为剩下的按钮绑定监听器实现跳转功能btn_search.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){Intentintent=newIntent(Main.this,Search.class);startActivity(intent);}});7btn_modify.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){Intentintent=newIntent(Main.this,Modify.class);startActivity(intent);}});btn_add.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){Intentintent=newIntent(Main.this,Add.class);startActivity(intent);}});btn_delete.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){Intentintent=newIntent(Main.this,Delete.class);startActivity(intent);}});btn_quit.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewsource){db.close();finish();}});}}2.数据显示界面:8按姓名排列,点击条目展开具体信息核心代码:publicclassSearchResultextendsActivity{@SuppressLint(RtlHardcoded)publicvoidonCreate(BundlesavedInstanceState){requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//获取传送来的数据super.onCreate(savedInstanceState);setContentView(R.layout.layout_result);finalIntentintent=getIntent();BaseExpandableListAdapteradapter=newBaseExpandableListAdapter(){9//提取数据Bundlebundle=intent.getExtras();Studentmem_data=(Student)getIntent().getExtras().get(data);String[]people=(String[])bundle.getSerializable(name);String[][]data=mem_data.info;publicObjectgetChild(intgroupPosition,intchildPosition){returndata[groupPosition][childPosition];}publiclonggetChildId(intgroupPosition,intchildPosition){returnchildPosition;}publicintgetChildrenCount(intgroupPosition){returndata[groupPosition].length;}//设定每个子选项每行的显示方式privateTextViewgetTextView(){AbsListView.LayoutParamslp=newAbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);TextViewtextView=newTextView