• JAVA日报


    从零开始的体温app开发(dao1)

    package dao;


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

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

    import bean.User;
    import db.Sqlite;
    public class UserDao {
    private final Sqlite sqlite;
    private static UserDao userDao=null;
    private UserDao(Context context){
    sqlite =new Sqlite(context);
    }
    public static UserDao getInstance(Context context){
    if(userDao==null){
    userDao=new UserDao(context);
    }
    return userDao;
    }
    //保存
    public void insert(User user){
    SQLiteDatabase db=sqlite.getWritableDatabase();
    ContentValues values=new ContentValues();
    values.put("name",user.get("name"));
    values.put("num",user.get("num"));
    values.put("cl",user.get("cl"));
    values.put("date",user.get("date"));
    values.put("time",user.get("time"));
    values.put("area",user.get("area"));
    values.put("tem",user.get("tem"));
    values.put("qw",user.get("qw"));
    db.insert("text",null,values);
    db.close();
    }
    //获取
    public List<User> findAll(){
    SQLiteDatabase db=sqlite.getWritableDatabase();
    Cursor cursor=db.query("text",new String[]{"name","num","cl","date","time","area","tem","qw"},null,null,null,null,null);
    List<User> userList=new ArrayList<>();
    while(cursor.moveToNext()){
    User u=new User();
    u.setName(cursor.getString(0));
    u.setNum(cursor.getString(1));
    u.setCl(cursor.getString(2));
    u.setDate(cursor.getString(3));
    u.setTime(cursor.getString(4));
    u.setArea(cursor.getString(5));
    u.setTem(cursor.getString(6));
    u.setQw(cursor.getString(7));
    userList.add(u);
    }
    db.close();
    return userList;
    }

    }
  • 相关阅读:
    c# 无边框窗体显示任务栏菜单(系统菜单)
    C# 任务栏的相关信息
    C# 获取屏幕尺寸
    C# winform 中的Form 源码
    C# datagridview 的属性及事件
    C# datagridview 中添加下拉框,并绑定selectedindexchanged事件
    C# 键盘事件
    Struts2的国际化
    Struts2类型转换器
    Struts2的运行流程以及关键拦截器介绍
  • 原文地址:https://www.cnblogs.com/mumulailai/p/14909428.html
Copyright © 2020-2023  润新知