Android : SQLite 增删改查—简单应用

示例图:

学生实体类 Student.java

package com.example.mysqlite.dto;

public class Student {
    public Long id;
    public String name;
    public String sex;
    public int age;
    public String clazz;

    public String creatDate;

    //头像
    public byte[] logoHead;
    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", clazz='" + clazz + '\'' +
                ", creatDate='" + creatDate + '\'' +
                '}';
    }
}

工具类 DBhelpUtil.java

package com.example.mysqlite.util;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;

public class DBhelpUtil extends SQLiteOpenHelper {

    /**数据库名字*/
    public static final String DB_NAME = "studentDB";

    /**学生表字段信息*/
    public static final String TABLE_NAME = "tb_student";
    public static final String TB_NAME = "name";
    public static final String TB_SEX = "sex";
    public static final String TB_AGE = "age";
    public static final String TB_CLAZZ = "clazz";
    public static final String TB_CREATEDATE = "createDate";

    /**数据版本号 第一次运行要打开 */
//    public static final int DB_VERSION = 1;

    //模拟数据版本升级
    public static final int DB_VERSION = 2;



    /**
     *
     * @param context   上下文
     * @param name      数据库名字
     * @param factory   游标工厂 null
     * @param version   自定义的数据库版本
     */
    public DBhelpUtil(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    //数据库第一次创建时被调用
    @Override
    public void onCreate(SQLiteDatabase db) {
        //初始化 第一次 创建数据库
        StringBuilder sql = new StringBuilder();



        sql.append(" create table tb_student(");
        sql.append(" id integer primary key,  ");
        sql.append(" name varchar(20),");
        sql.append(" sex varchar(2),");
        sql.append(" age varchar(20),");
        sql.append(" clazz varchar(20),");
        sql.append(" createDate varchar(23) )");


//        Log.e("TAG","------"+sql.toString());

        //执行sql
        db.execSQL(sql.toString());
    }

    //版本号发生改变时调用
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //更新数据库 插入字段
        String sql = "alter table tb_student add logoHead varchar(200)";

        db.execSQL(sql);

    }
}

StudentDao.java

package com.example.mysqlite.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.AbstractWindowedCursor;
import android.database.Cursor;
import android.database.CursorWindow;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;

import com.example.mysqlite.dto.Student;
import com.example.mysqlite.util.DBhelpUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.SimpleFormatter;

public class StudentDao {
    private DBhelpUtil dBhelpUtil;


    /**相当于获得一个链接数据库的对象*/
    private SQLiteDatabase DB;
    private Context context;
    public StudentDao(Context context,DBhelpUtil dBhelpUtil){
        this.context =context;
        this.dBhelpUtil = dBhelpUtil;
    }
    //保存数据
    public Long save(Student student) {
        /** 获取一个写 操作数据的对象*/
        DB = dBhelpUtil.getWritableDatabase();

        ContentValues contentValues = new ContentValues();
        contentValues.put(DBhelpUtil.TB_NAME,student.name);
        contentValues.put(DBhelpUtil.TB_SEX,student.sex);
        contentValues.put(DBhelpUtil.TB_AGE,student.age);
        contentValues.put(DBhelpUtil.TB_CLAZZ,student.clazz);

//        Log.e("TAG","--------------"+student.toString());
//        Toast.makeText(context,"sql 语句--"+student.toString(),Toast.LENGTH_LONG).show();
        //时间
        Date date = new Date();
        //格式化
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        contentValues.put(DBhelpUtil.TB_CREATEDATE, simpleDateFormat.format(date));


        /**insert()
         * String table: 表名
         * String nullColumnHack: 不允许插入空行,为了防止插入空行,可以在这里随便指定一列, 如果有空值插入 会用null表示,好像没作用~
         * ContentValues values 数据行数据
         * 返回值 成功插入行号的id  ,插入失败 -1
         */
        return DB.insert(DBhelpUtil.TABLE_NAME,"空值",contentValues);
        //INSERT INTO tb_student(id,age,sex,name,clazz,createDate) VALUES (?,?,?,?,?,?)

    }

    /**查询数据*/
    public List<Student> select(Long id) {
        /** 获取一个读 操作数据的对象*/
        DB =dBhelpUtil.getReadableDatabase();

        /**query() 查询数据
         *String table, 表名
         * String[] columns, 要查询要显示的列
         * String selection,   查询条件
         * String[] selectionArgs, 参数值
         * String groupBy, 分组
         * String having, 分组后的条件
         * String orderBy 排序
         * 返回游标 Cursor
          */
        String[] columns = new String[]{
                "id",
                DBhelpUtil.TB_NAME,
                DBhelpUtil.TB_SEX,
                DBhelpUtil.TB_AGE,
                DBhelpUtil.TB_CLAZZ,
                DBhelpUtil.TB_CREATEDATE
        };
        Cursor cursor = null;
        if(id == null){
            //全查
             cursor = DB.query(DBhelpUtil.TABLE_NAME,columns,null,null,null,null,"id desc");
        }else {
            //根据id 查询
            cursor = DB.query(DBhelpUtil.TABLE_NAME,columns,"id=?",new String[]{String.valueOf(id)},null,null,null);

        }

        List<Student> studentList = new ArrayList<>();
        if(cursor != null){
            //遍历游标
            while(cursor.moveToNext()){
                Student student = new Student();
                // 根据游标找到列  在获取数据
                student.id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));
                student.name = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_NAME));
                student.sex = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_SEX));
                student.age = cursor.getInt(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_AGE));
                student.clazz = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CLAZZ));
                student.creatDate = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CREATEDATE));

                //添加到集合
                studentList.add(student);
            }
        }

        cursor.close();

        return studentList;
    }
    /**删除数据*/
    public int delete(Long id) {
        // 获取操作数据库对象
        DB = dBhelpUtil.getWritableDatabase();

        /**
         * String table,  表名
         * String whereClause, 条件
         * String[] whereArgs 参数
         * 返回影响行数,失败 0
         */
        //全部删除
        if(id == null){
            return DB.delete(DBhelpUtil.TABLE_NAME,null,null);
        }
        // 条件查询
       return DB.delete(DBhelpUtil.TABLE_NAME,"id = ?",new String[]{id+""});
    }

    /**保存位图*/
    public void saveBitmap(Student student) {
        /** 获取一个写 操作数据的对象*/
        DB = dBhelpUtil.getWritableDatabase();
        //开启事务
        DB.beginTransaction();


         //时间
        Date date = new Date();
        //格式化
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //执行sql语句 方式
        String sql = "INSERT INTO tb_student(age,sex,name,clazz,createDate,logoHead) VALUES (?,?,?,?,?,?)";
        /**
         * sql 语句
         * 要插入的数据
         */
        DB.execSQL(sql,new Object[]{student.age,student.sex,student.name,student.clazz,simpleDateFormat.format(date),student.logoHead});

        //设置事务成功
        DB.setTransactionSuccessful();
        //添加事务
        DB.endTransaction();


    }

    //查询位图
    public Student selectBitmapById(Long id) {
        /** 获取一个读 操作数据的对象*/
        DB =dBhelpUtil.getReadableDatabase();
        Cursor cursor = null;


        /** 根据id 查询 返回一个游标对象
         * String sql,
         * String[] selectionArgs,
         * select * from tb_student where id = ?
         */
        cursor = DB.rawQuery("select * from "+ DBhelpUtil.TABLE_NAME+" where id =?",new String[]{id+""});
        // 解决报错;android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
        CursorWindow cw = new CursorWindow("test", 5000000); // 设置CursorWindow的大小为5000000
        AbstractWindowedCursor ac = (AbstractWindowedCursor) cursor;
        ac.setWindow(cw);

        Student student = null;
        if(cursor != null){
            if(cursor.moveToNext()){
                student = new Student();
                // 根据游标找到列  在获取数据
                student.id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));
                student.name = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_NAME));
                student.sex = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_SEX));
                student.age = cursor.getInt(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_AGE));
                student.clazz = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CLAZZ));
                student.creatDate = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CREATEDATE));
                //图片
                student.logoHead =cursor.getBlob(cursor.getColumnIndexOrThrow("logoHead")) ;
            }
        }
        cursor.close();

        return student;
    }


    //按条件修改
    public int updateById(Student student,Long id){
        // 获取写操作数据库对象
        DB = dBhelpUtil.getWritableDatabase();
        //开启事务
        DB.beginTransaction();
        /**
         * String table,
         * ContentValues values, 数据行数据
         * String whereClause, 条件
         * String[] whereArgs   参数
         * 返回影响行数
         */
        //数据行数据
        ContentValues contentValues = new ContentValues();
        contentValues.put(DBhelpUtil.TB_NAME,student.name);
        contentValues.put(DBhelpUtil.TB_SEX,student.sex);
        contentValues.put(DBhelpUtil.TB_AGE,student.age);
        contentValues.put(DBhelpUtil.TB_CLAZZ,student.clazz);

        //时间
        Date date = new Date();
        //格式化
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        contentValues.put(DBhelpUtil.TB_CREATEDATE, simpleDateFormat.format(date));

        int result = DB.update(DBhelpUtil.TABLE_NAME,contentValues,"id = ?", new String[]{id+""});
        //完成事务
        DB.setTransactionSuccessful();
        //结束事务
        DB.endTransaction();

       return result;
    }
}

MainActivity.java

package com.example.mysqlite;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mysqlite.activity.BaseActivity;
import com.example.mysqlite.dao.StudentDao;
import com.example.mysqlite.dto.Student;
import com.example.mysqlite.util.DBhelpUtil;

import java.io.ByteArrayOutputStream;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private Context mContext;

    private EditText etName,etSex,etAge,etClass;
    private EditText etSelectID,etDeleteID;
    private Button btnSave,btnSelect,btnDelete,btnSaveBitmap,btnSelectBitmap,btnUpdate;
    private TextView textView;
    private ImageView imageView;

    private DBhelpUtil dBhelpUtil;
    private StudentDao studentDao;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;

        etName = findViewById(R.id.et_name);
        etSex = findViewById(R.id.et_sex);
        etAge = findViewById(R.id.et_age);
        etClass = findViewById(R.id.et_class);

        etSelectID =findViewById(R.id.et_select_id);
        etDeleteID = findViewById(R.id.et_delete_id);

        textView =findViewById(R.id.tv_data);
        imageView = findViewById(R.id.iv_image);

        //按钮
        btnSave = findViewById(R.id.tbn_save);
        btnSelect = findViewById(R.id.tbn_select);
        btnDelete = findViewById(R.id.tbn_delete);
        btnSaveBitmap = findViewById(R.id.btn_save_bitmap);
        btnSelectBitmap = findViewById(R.id.tbn_select_bitmap);
        btnUpdate = findViewById(R.id.btn_update);



        /**
         *
         * @param context   上下文
         * @param name      数据库名字
         * @param factory   游标工厂 null
         * @param version   自定义的数据库版本
         */
        dBhelpUtil = new DBhelpUtil(mContext,DBhelpUtil.DB_NAME,null,DBhelpUtil.DB_VERSION);
        studentDao = new StudentDao(MainActivity.this,dBhelpUtil);
        //保存数据事件
        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //保存数据方法
                setDataSave();
            }
        });


        // 查询事件
        btnSelect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               //查询数据
                selectDataByID();
            }
        });

        //修改事件
        btnUpdate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                updateData();
            }
        });

        //删除事件
        btnDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                deleteDataById();
            }
        });

        //跟新数据库版本后 增加了字段插入图片
        btnSaveBitmap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    // 获取文本信息
                    Student student = new Student();
                    student.name = etName.getText().toString();
                    student.sex = etSex.getText().toString();
                    student.age = Integer.valueOf(etAge.getText().toString());
                    student.clazz = etClass.getText().toString();

                    //图片
                    // 获取图片位图
                    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.logo);
                    //字节数组输出流
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    /** 把位图 转换 成字节数组输出流
                     *CompressFormat format,  格式
                     * int quality, 质量 0 - 100
                     * OutputStream stream 输出流
                     */
                    bitmap.compress(Bitmap.CompressFormat.JPEG,100,out);

                    student.logoHead = out.toByteArray();

                    studentDao.saveBitmap(student);
                    showToast("保存数据成功!");
                }catch (Exception e){
                    showToast("保存数据失败"+e.getMessage());
                }

            }
        });

        //查询展示图片
        btnSelectBitmap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectBitmapMethod();
            }
        });

    }




    /**保存数据*/
    public void setDataSave(){
        try {

            Student student = new Student();
            student.name = etName.getText().toString();
            student.sex = etSex.getText().toString();
            student.age = Integer.valueOf(etAge.getText().toString());
            student.clazz = etClass.getText().toString();

            Long result = studentDao.save(student);

            if(result != -1){
//                       Toast.makeText(getApplication(),"保存数据成功!返回插入行号是["+result+"]",Toast.LENGTH_SHORT).show();
                showToast("保存数据成功!返回插入行号是["+result+"]");
            }else{
                showToast("保存数据失败result["+result+"]");
            }

        }catch ( Exception e){
            e.printStackTrace();
        }
    }

    /**查询数据*/
    public void selectDataByID(){
        Long id = etSelectID.getText().toString().equals("") || etSelectID.getText().toString().equals(null) ? null:Long.valueOf(etSelectID.getText().toString());
        List<Student> data = studentDao.select(id);

        if(data.equals(null) || data.size() == 0){
            textView.setText("没有查到数据!");
        }else {
            textView.setText(data.toString());
        }

    }

    /**删除数据*/
    public  void deleteDataById(){
        Long id = etDeleteID.getText().toString().equals("") || etDeleteID.getText().toString().equals(null) ? null : Long.valueOf(etDeleteID.getText().toString());
        int result = studentDao.delete(id);
        if(result != 0){
            showToast("删除数据成功!删除了["+result+"]条记录!");
        }else{
            showToast("删除数据失败result["+result+"]");
        }


    }

    /**查询展示图片*/
    public void selectBitmapMethod(){
        try {
            Long id = etSelectID.getText().toString().equals("") || etSelectID.getText().toString().equals(null) ? 1:Long.valueOf(etSelectID.getText().toString());
            Student data = studentDao.selectBitmapById(id);
            if(data != null){
                // 把数据显示到页面
                etName.setText(data.name);
                etSex.setText(data.sex);
                etAge.setText(data.age+"");
                etClass.setText(data.clazz);
                //有数据再转
                if(data.logoHead != null){
                    textView.setText(" ");
                    // 把字节数组 转成位图
                    Bitmap bitmap = BitmapFactory.decodeByteArray(data.logoHead,0,data.logoHead.length);
                    imageView.setImageBitmap(bitmap);
                }else{
                    textView.setText("没有图片数据!");
                }

            }else{
                textView.setText("没有查到数据!");
            }



        }catch (Exception e){
            e.printStackTrace();
            showToast("查询失败"+e.getMessage());
        }

    }

    /**更新**/
    public void updateData(){
        Long id = etDeleteID.getText().toString().equals("") || etDeleteID.getText().toString().equals(null) ? 1 : Long.valueOf(etDeleteID.getText().toString());

        Student student = new Student();
        student.name = etName.getText().toString();
        student.sex = etSex.getText().toString();
        student.age = Integer.valueOf(etAge.getText().toString());
        student.clazz = etClass.getText().toString();

        int result = studentDao.updateById(student,id);
        if(result != 0){
            showToast("修改数据成功!修改了["+result+"]条记录!");
        }else{
            textView.setText("没有【"+ id +"】这条记录!");
            showToast("修改数据失败result["+result+"]");
        }

    }

    public void showToast(String msg) {
        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
    }

    //异步弹框
    public void showToastSync(String msg) {
        Looper.prepare();
        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
        Looper.loop();
    }
}

布局 activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="SQLite 简单应用:"
    android:textSize="24sp"
    />
    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            android:text="姓名:"
            />

        <EditText
            android:id="@+id/et_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            android:text="性别:"
            />

        <EditText
            android:id="@+id/et_sex"
            android:inputType="text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            android:text="年龄:"
            />

        <EditText
            android:id="@+id/et_age"
            android:inputType="number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            android:text="班级:"
            />

        <EditText
            android:id="@+id/et_class"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/tbn_save"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="保存数据"
            android:textSize="14sp"/>

        <Button
            android:id="@+id/btn_save_bitmap"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="更新数据库版本后保存图片"
            android:textSize="12sp"/>
    </LinearLayout>



    <!-- 查询-->
    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:inputType="number"
            android:id="@+id/et_select_id"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />

        <Button
            android:id="@+id/tbn_select"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="查询数据"
            android:textSize="12sp"/>
        <Button
            android:id="@+id/tbn_select_bitmap"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="根据id查询图片"
            android:textSize="12sp"/>


    </LinearLayout>

    <!-- 删除-->
    <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:inputType="number"
            android:id="@+id/et_delete_id"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:textSize="24sp"
            />

        <Button
            android:id="@+id/tbn_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="删除数据"
            android:textSize="14sp"/>
        <Button
            android:id="@+id/btn_update"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="根据id修改"
            android:textSize="12sp"/>


    </LinearLayout>

    <ScrollView
        android:background="#ccc"
        android:layout_width="match_parent"
        android:layout_height="120dp">

        <!-- 显示查询结果-->
        <TextView
            android:layout_marginLeft="10dp"
            android:textColor="#ff00ff00"
            android:textSize="22sp"
            android:id="@+id/tv_data"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </ScrollView>


    <ImageView
        android:id="@+id/iv_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</LinearLayout>

源码地址:GitCode - 开发者的代码家园

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/210368.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

分享一个判断曲线的趋势的Demo

需求背景 最近在处理数据&#xff0c;横坐标是时间&#xff0c;纵坐标是价格&#xff0c;需要判断一段时间内&#xff0c;由这些点绘制成的曲线的走势&#xff0c;比如趋势朝上&#xff0c;趋势朝下&#xff0c;水平调整这三种趋势。尝试了不少方法&#xff0c;下面这个效果还…

以热爱的态度对待生活,就是最自己的温柔

粉色系拼接款羽绒服 90白鸭绒&#xff0b;连帽立领设计 防风又保暖&#xff0c;柔软蓬松舒适感十足 衣服上加了时尚的字母印花元素 袖口做了魔术贴设计 下摆也做了可调节抽绳 防风保暖五部做到实处哦 宽松版型&#xff0c;很耐穿保暖性又很强 简单大方&#xff0c;搭配…

Flutter:视频下载案例

前言 最近在研究视频下载&#xff0c;因此打算一边研究一边记录一下。方便以后使用时查看。 使用到的库有&#xff1a; permission_handler 11.1.0 &#xff1a;权限请求 flutter_downloader 1.11.5&#xff1a;文件下载器 path_provider 2.1.1&#xff1a;路径处理 视频…

基于springboot 图书馆管理系统

qq&#xff08;2829419543&#xff09;获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;springboot 前端&#xff1a;采用vue技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xf…

网络编程之套接字

端口 && IP 在学习套接字编程之前&#xff0c;我们必须了解一下前缀知识。首先是IP和端口的作用。 在这之前&#xff0c;我们要明白一件事。那就是把数据从一台主机发送到另一台主机&#xff0c;是目的吗&#xff1f;&#xff1f;&#xff1f;当然不是&#xff01;&a…

Hdoop学习笔记(HDP)-Part.20 安装Flume

目录 Part.01 关于HDP Part.02 核心组件原理 Part.03 资源规划 Part.04 基础环境配置 Part.05 Yum源配置 Part.06 安装OracleJDK Part.07 安装MySQL Part.08 部署Ambari集群 Part.09 安装OpenLDAP Part.10 创建集群 Part.11 安装Kerberos Part.12 安装HDFS Part.13 安装Ranger …

java学习part27线程死锁

基本就是操作系统的内容 138-多线程-线程安全的懒汉式_死锁_ReentrantLock的使用_哔哩哔哩_bilibili

基于SpringBoot+Vue的前后端分离的房屋租赁系统2

✌全网粉丝20W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取项目下载方式&#x1f345; 一、项目背景介绍&#xff1a; 开发过程中&#xff0…

基于Django框架搭建的协同过滤算法电影推荐网站-爬取的豆瓣电影数据

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介概述技术栈实现流程 二、功能三、系统四. 总结 一项目简介 # 电影推荐网站介绍 概述 该电影推荐网站是基于Django框架搭建的&#xff0c;旨在为用户提供个…

前端文本省略号后面添加复制文字

前端文本省略号后面添加复制文字 1、效果图 2、代码展示 <div class"link-content-wrap" click"copyLinkText"><div class"link-content">{{ shareResult.url || }} </div><span class"show-ellipsis" click&…

Linux MIPI 调试中常见的问题

一、概述 做嵌入式工作的小伙伴知道&#xff0c;有时候程序编写没有调试过程中费时&#xff0c;之间笔记里有 MIPI 摄像头驱动开发的过程&#xff0c;有需要的小伙伴可以参考&#xff1a;Linux RN6752 驱动编写。而我也是第一次琢磨 MIPI 协议&#xff0c;其中有很多不明白的地…

本科毕业生个人简历23篇

刚毕业的本科生如何制作一份令招聘方印象深刻的简历&#xff1f;可以参考以下这23篇精选的本科毕业生应聘简历案例&#xff01;无论您的专业是什么&#xff0c;都能从中汲取灵感&#xff0c;提升简历质量&#xff0c;轻松斩获心仪职位&#xff01;小伙伴们快来看看吧&#xff0…

LeetCode刷题---合并两个有序链表

个人主页&#xff1a;元清加油_【C】,【C语言】,【数据结构与算法】-CSDN博客 个人专栏&#xff1a;http://t.csdnimg.cn/ZxuNL http://t.csdnimg.cn/c9twt 前言&#xff1a;这个专栏主要讲述递归递归、搜索与回溯算法&#xff0c;所以下面题目主要也是这些算法做的 我讲述…

3D模型材质编辑

在线工具推荐&#xff1a; 三维数字孪生场景工具 - GLTF/GLB在线编辑器 - Three.js AI自动纹理化开发 - YOLO 虚幻合成数据生成器 - 3D模型在线转换 - 3D模型预览图生成服务 如今&#xff0c;3D 纹理、打印和建模都非常流行。使用可用的高级工具&#xff0c;创建 3D 模型…

24双非硕的秋招总结

24 双非硕的秋招总结 结果&#xff1a; 运气捡漏去了腾讯 想想自己整个研究生学习过程&#xff0c;还是挺坎坷的&#xff0c;记录一下&#xff0c;也给未来的同学提供一些参考。 研一 我是研一上开始学前端的&#xff0c;应该是21年10月份左右&#xff0c;我们实验室是专门…

Nacos多数据源插件

Nacos从2.2.0版本开始,可通过SPI机制注入多数据源实现插件,并在引入对应数据源实现后,便可在Nacos启动时通过读取application.properties配置文件中spring.datasource.platform配置项选择加载对应多数据源插件.本文档详细介绍一个多数据源插件如何实现以及如何使其生效。 注意:…

DOM 事件的传播机制

前端面试大全DOM 事件的传播机制 &#x1f31f;经典真题 &#x1f31f;事件与事件流 事件流 事件冒泡流 事件捕获流 标准 DOM 事件流 &#x1f31f;事件委托 &#x1f31f;真题解答 &#x1f31f;总结 &#x1f31f;经典真题 谈一谈事件委托以及冒泡原理 &#x1f3…

134. 加油站(贪心算法)

根据题解 这道题使用贪心算法&#xff0c;找到当前可解决问题的状态即可 「贪心算法」的问题需要满足的条件&#xff1a; 最优子结构&#xff1a;规模较大的问题的解由规模较小的子问题的解组成&#xff0c;规模较大的问题的解只由其中一个规模较小的子问题的解决定&#xff…

蓝桥第一期模拟总结

文章目录 1.动态的 Tab 栏2.地球漫游3.迷惑的this4.燃烧卡路里5.魔法失灵了6.年龄统计 所有题目链接 1.动态的 Tab 栏 本题要实现一个tab栏固定效果&#xff0c;看见题目就想到css中的 position: fixed; 尝试了很久都没能实现效果&#xff0c;后来又想到了粘性定位 position: …

【深度学习】深度学习框架的环境配置

目录 1. 配置cuda环境 1.1. 安装cuda和cudnn 1.1.1. 显卡驱动配置 1.1.2. 下载安装cuda 1.1.3. 下载cudnn&#xff0c;将解压后文件复制到cuda目录下 1.2. 验证是否安装成功 2. 配置conda环境 2.1. 安装anaconda 2.2. conda换源 2.3. 创建conda环境 2.4. pip换源 3…
最新文章