简单记事本app7

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;
}
//全局浏览
//未实现
}
posted @   椰子灰  阅读(34)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示