• 第一阶段冲刺第六天


    1、今天自己做的是建立了数据库。准备将产生的数据存放到数据库之中。

    主要的数据库代码人如下:

    复制代码
    package com.example.dingwei2.DBOpenMessageUser;
    
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;
    
    import androidx.annotation.Nullable;
    
    import com.example.dingwei2.bean.location;
    
    public class DBOpenMessageUserlocation extends SQLiteOpenHelper
    {
        final String db_location="create table db_location (_id integer primary key autoincrement,username varchar,date varchar,points varchar,distance integer,time varchar,energy integer,speed integer)";
        public DBOpenMessageUserlocation(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
            super(context, name, null, version);
        }
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(db_location);
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("数据","更新"+"oldVerSion"+"-->"+newVersion);
        }
    
        /**
        *数据库的相关操作
        * **/
        //增加信息
        public void insertlocation(SQLiteDatabase sqLiteDatabase, location location) {
            ContentValues cv = new ContentValues();
            cv.put("username", location.username);
            cv.put("date", location.date);
            cv.put("points", location.points);
            cv.put("time", location.time);
            cv.put("distance", location.distance);
            cv.put("energy", location.energy);
            cv.put("speed", location.speed);
            sqLiteDatabase.insert(db_location, null, cv);
        }
    //删除信息
        public void deletebyid(Integer id)
        {
            SQLiteDatabase database = getWritableDatabase();
            database.execSQL("delete from db_location where id=?", new String[]{String.valueOf(id)});
        }
        //查找
           // database.execSQL("delete from db_location where  date=? and username=?", new String[]{date,username});
    
        public Cursor getAllLocation(String username) {
            SQLiteDatabase database = getWritableDatabase();
            return database.query("db_wen", null, "username=?",new String[]{username},null, null,"distance desc" );//"userdata desc"
        }
    
    
    //    public void updatauser(String username,String usercheck)
    //    {
    //        SQLiteDatabase database = getWritableDatabase();
    //        ContentValues values=new ContentValues();
    //        values.put("usercheck",usercheck);
    //        database.update("db_wen",values,"username=?",new String[]{username});
    //    }
    //    public void updatauserpicture(String username,String userpicture)
    //    {
    //        SQLiteDatabase database = getWritableDatabase();
    //        ContentValues values=new ContentValues();
    //        values.put("userpicture",userpicture);
    //        database.update("db_wen",values,"username=?",new String[]{username});
    //    }
    //    public void updatapassword(String username,String password)
    //    {
    //        SQLiteDatabase database = getWritableDatabase();
    //        ContentValues values=new ContentValues();
    //        values.put("password",password);
    //        database.update("db_wen",values,"username=?",new String[]{username});
    //    }
    }
  • 相关阅读:
    团队项目冲刺第6天
    冲刺阶段第五天
    冲刺阶段前四天总结
    "博客园"用户体验分析
    测试计划
    scrum敏捷开发
    团队开发_软件项目风险管理
    sprint计划会议
    svn 之 svn的两种开发模式
    redis 之 搭建真实集群
  • 原文地址:https://www.cnblogs.com/wwbzuiku/p/12876023.html
Copyright © 2020-2023  润新知