• 个人冲刺--体温五


    体温录入

    复制代码
    public void insertDB(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"amydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            ContentValues contentvalues=new ContentValues();
            text1=(EditText)findViewById(R.id.tv_text1);
            text2=(EditText)findViewById(R.id.tv_text2);
            text3=(EditText)findViewById(R.id.tv_text3);
            text4=(EditText)findViewById(R.id.tv_text4);
            contentvalues.put("name",text1.getText().toString());
            contentvalues.put("dateandtime",text2.getText().toString());
            contentvalues.put("address",text4.getText().toString());
            contentvalues.put("wendu",text3.getText().toString());
            long flag=sqldb.insert("personwendu",null,contentvalues);
            Toast.makeText(this,"数据加入成功"+flag,Toast.LENGTH_LONG).show();
        }
    复制代码

    体温记录删除

    复制代码
    public void deleteDate(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"mydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            int flag=sqldb.delete("person","id=1",null);
            Toast.makeText(this,"已有"+flag+"条数据删除",Toast.LENGTH_LONG).show();
        }
    复制代码

    体温修改

    复制代码
    public void updateData(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"mydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            ContentValues contentvalues=new ContentValues();
            contentvalues.put("name","明明");
            contentvalues.put("age","12");
            int flag=sqldb.update("person",contentvalues,"name=?",new String[]{"李明"});
            Toast.makeText(this,"已有"+flag+"条数据修改",Toast.LENGTH_LONG).show();
        }
    复制代码

    历史记录查询

    复制代码
     public void queryData(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"amydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            Cursor cursor=sqldb.rawQuery("select * from personwendu",null);
            String str="";
            if(cursor.moveToFirst())
            {
                do{
                    String name=cursor.getString(cursor.getColumnIndex("name"));
                    String dateandtime=cursor.getString(cursor.getColumnIndex("dateandtime"));
                    String address=cursor.getString(cursor.getColumnIndex("address"));
                    String wendu=cursor.getString(cursor.getColumnIndex("wendu"));
                    str=str+name+"|"+dateandtime+"|"+wendu+"
    "+address+"
    ";
                }while(cursor.moveToNext());
            }
            AlertDialog.Builder builder=new AlertDialog.Builder(this);
            builder.setTitle("历史记录").setIcon(R.mipmap.ic_launcher).setMessage(str)
                    .setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });
            AlertDialog ad=builder.create();
            ad.show();
        
  • 相关阅读:
    设计模式-观察者模式
    ps一寸照的编辑
    ps剪切蒙版的使用
    ps扣头发
    mysql索引优化
    ES6 $ ES5
    sping-mybatis集成
    多线程--volatile
    eclipse.exe打开是报错
    Spring Aop 详解二
  • 原文地址:https://www.cnblogs.com/zhaoyuxiao000/p/14908580.html
Copyright © 2020-2023  润新知