首页 > 其他分享 >简单记事本app7

简单记事本app7

时间:2023-03-18 23:44:23浏览次数:26  
标签:String app7 sql db 简单 import password id 记事本

CRDU部分(不完全)

package db;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

//负责管理数据库的类,主要对表中的内容进行操作,CRUD
public class DBManager {
private static SQLiteDatabase db;
//初始化数据库
public static void initDB(Context context){
//得到帮助类对象
DBOpenhelper helper = new DBOpenhelper(context);
//得到数据库对象
db = helper.getWritableDatabase();
}
///////////////////////////////////////////////////////////////////////////////
//用户数据操作
//登录(查找)
public static Boolean getUserstart(String id, String password){
UserBean user = new UserBean();
String sql = "select * from user where id =? and password =?";
Cursor cursor = db.rawQuery(sql,new String[]{id, password});
if(cursor.moveToNext() == true){
cursor.close();
return true;
}
return false;
}
//注册检测
public static Boolean getUserlogin(String id, String name,
String uno, String classs, String phone, String password){
String sql = "insert into user (id, name, uno, classs, phone,password) values (?, ?, ?, ?, ?, ?)";
Object obj[]={id, name, uno, classs, phone, password};
db.execSQL(sql, obj);
return true;
}

//////////////////////////////////////////////////////////////////////////////////////////////
//事件数据操作
//添加事件
public static Boolean insertNote(String title, String keywords, String contents){
//自动获取系统时间
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy/MM/dd");
String daytime = sDateFormat.format(new java.util.Date());

String sql = "insert into note (title,keywords,contents,daytime) values (?, ?, ?, ?)";
Object obj[]={title, keywords, contents, daytime};
db.execSQL(sql, obj);
return true;
}
//全局浏览
//未实现
}

标签:String,app7,sql,db,简单,import,password,id,记事本
From: https://www.cnblogs.com/yansans/p/17232228.html

相关文章

  • 简单记事本app2
    ——注册——activity_login.xml注册页面设计<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"......
  • 简单记事本app3
    ——登录之后——activity_function.xml   ListView实现滚动浏览,不过这一部分还没做完,目前浏览操作还没有连接上数据库<?xmlversion="1.0"encoding="utf-8"?><Li......
  • 简单的记事本app1
    (因为时间原因功能尚不全面,之后会继续更新)放一下目录结构,大体会用到这些——(有对应activity.xxx.xml的,创建的时候要创建activity,不要单独创建java文件)   ——这一篇......
  • nchan 集成keydb简单测试&一些说明
    因为keydb是完整兼容redis的,所以对于单机版本的兼容是很简单的,配置就行了参考单机运行docker-compose文件version:'3'services:db3:imag......
  • maven的原理、配置与简单应用
    目录1Java中的依赖和jar文件2依赖仓库的设计与实现3maven项目 - 3.1maven的配置:配置settings.xml、建立本地仓库目录maven-repo - 3.2maven的使用:以Spring......
  • 【基础算法】简单排序-冒泡排序
    【基础算法】简单排序-冒泡排序BubbleSortisthesimplestsortingalgorithmthatworksbyrepeatlyswappingtheadjacentelementsiftheyareinthewrongorde......
  • 一次简单的性能测试记录
     性能测试1.性能测试的场景:对性能压测接口:抢购进行测试 过程:刚开始没有提供接口,自己去页面抓包然后通过登录接口获取token才能去验证"藏品详情""藏品列......
  • 简单高效的打字学习软件:Master of Typing 3 Mac版
    想要提升打字速度,一款好用的打字学习软件必不可少,今天推荐MasterofTyping3Mac版给大家,一款帮助用户提高打字技巧的打字游戏。它具有不同难度级别的多个级别,可以测试和......
  • REST风格下的SpringMVC简单响应方法
    学习中,如有错误请见谅  项目结构   ServletContainersInitConfigpublicclassServletContainersInitConfigextendsAbstractAnnotationConfigDispatcher......
  • SpringMVC 简单响应
    学习中,如有错误请多包涵项目结构  @Configuration@ComponentScan("com.itheima.controller")//开启json数据类型自动转换@EnableWebMvcpublicclassSpringMvc......