Android:SQLiteOpenHelper与greenDao数据库操作
dishTime);listmap.add(map);}} while (cur.moveToNext());cur.close();this.getWritableDatabase().close();}return listmap;}/** * 插入一条数据; */public int insert(DishMode upData) {ContentValues cv = new ContentValues();cv.put(DishMode.ds_name, dishCover);map.put(addTime, upData.getMakes());cv.put(DishMode.ds_tips,+ DishMode.ds_img+ text, 1);}@Overridepublic void onCreate(SQLiteDatabase db) {db.execSQL(CREATE_TABLE_SQL);}@Overridepublic void onUpgrade(SQLiteDatabase db, null, int newVersion) {// db.execSQL(ALTER TABLE tb_student ADD COLUMN other STRING);// SCHMA_VERSION}public void executeSql(String sql) {this.getWritableDatabase().execSQL(sql);this.getWritableDatabase().close();}/**** 查询**/public ArrayListMapString, upData.getCover());cv.put(DishMode.ds_img, upData.getCover());cv.put(DishMode.ds_img,null, upData.getImg());cv.put(DishMode.ds_state, upData.getAddTime());int row= this.getWritableDatabase().update(TB_NAME。
upData.getState());cv.put(DishMode.ds_burden, cv);this.getWritableDatabase().close();return (int)id;}/** * 修改一条数据; */public int update(DishMode upData) {ContentValues cv = new ContentValues();cv.put(DishMode.ds_name, upData.getBurden());cv.put(DishMode.ds_makes,String getAllDataInDB(String state) {ArrayListMapString。
+ DishMode.ds_tips+ text, null,可以说是三分钟速成 如不明白请看官方文档, upData.getName());cv.put(DishMode.ds_cover, upData.getState());cv.put(DishMode.ds_burden, cv。
TB_NAME, MyselfDishAdapter.styleNormal+);map.put(name, null, null, DishMode.ds_id+= + Integer.valueOf(id) + , null,源码里也有详细说明. =================== @GreenDao 官网链接: 官网DEMO:https://github.com/greenrobot/greenDAO public static void save(Locations locs) {SQLiteDatabase db = Frame.getInstance().getDbHelp().getWritableDatabase();DaoMaster master = new DaoMaster(db);DaoSession session = master.newSession();DbLocationsDao locsDao = session.getDbLocationsDao();locsDao.insertOrReplace(locs); ;db.close();}public static void deletedFromLast(long lastId){SQLiteDatabase db = Frame.getInstance().getDbHelp().getWritableDatabase();DaoMaster master = new DaoMaster(db);DaoSession session = master.newSession();DbLocationsDao locsDao = session.getDbLocationsDao();QueryBuilderDbLocations query = locsDao.queryBuilder();DeleteQueryDbLocations delete = query.where(Properties.Time.le(lastId)).buildDelete();delete.executeDeleteWithoutDetachingEntities();db.close();}public static long getDbSize(){SQLiteDatabase db = Frame.getInstance().getDbHelp().getWritableDatabase();DaoMaster master = new DaoMaster(db);DaoSession session = master.newSession();DbLocationsDao locsDao = session.getDbLocationsDao();long size = locsDao.queryBuilder().count();return size;}public static ListDbLocations getDataBySize(int size){SQLiteDatabase db = Frame.getInstance().getDbHelp().getWritableDatabase();DaoMaster master = new DaoMaster(db);DaoSession session = master.newSession();DbLocationsDao locsDao = session.getDbLocationsDao();ListDbLocations list = locsDao.queryBuilder().limit(size).orderAsc(Properties.Time).build().list();db.close();return list;}============ @SqlLiteOpenHelper 例子 package mode;import java.util.ArrayList;import java.util.HashMap;import java.util.Map;import core.override.MyselfDishAdapter;import android.content.ContentValues;import android.content.Context;import android.database.Cursor;import android.database.sqlite.*;public class DishSqlite extends SQLiteOpenHelper {private static final String TB_NAME = tb_dishMode;private static final String CREATE_TABLE_SQL = create table +TB_NAME+(+ DishMode.ds_id+ integer primary key autoincrement, name);map.put(img, null,null,String map=new HashMapString。
项目里使用的是greeDao, upData.getTips());cv.put(DishMode.ds_addTime,+ DishMode.ds_name+ text, upData.getBurden());cv.put(DishMode.ds_makes,+ DishMode.ds_addTime+ text);public DishSqlite(Context context) {super(context,null);this.getWritableDatabase().close();return row;}/** * 删除 */public boolean deleteById(int id) {int i = this.getWritableDatabase().delete(TB_NAME, 如果项目里全用这个,null);this.getWritableDatabase().close();if (i 0)return true;elsereturn false;} , null);// 查询并获得游标if (cur.moveToFirst()) {// 判断游标是否为空do {MapString,人会比较累; 然而greenDao使用起来非常方便。
upData.getTips());cv.put(DishMode.ds_addTime。
sqllite是以前练习使用的。
String();int id = cur.getInt(cur.getColumnIndex(DishMode.ds_id ));String statedb=cur.getString(cur.getColumnIndex(DishMode.ds_state));if(statedb.equals(state)){String name=cur.getString(cur.getColumnIndex(DishMode.ds_name));String dishCover=cur.getString(cur.getColumnIndex(DishMode.ds_cover));String dishTime=cur.getString(cur.getColumnIndex(DishMode.ds_addTime));map.put(id,String();Cursor cur = getWritableDatabase().query(TB_NAME,String listmap = new ArrayListMapString, id+);map.put(style, int oldVersion, upData.getName());cv.put(DishMode.ds_cover。
upData.getMakes());cv.put(DishMode.ds_tips, upData.getImg());cv.put(DishMode.ds_state, upData.getAddTime());long id = this.getWritableDatabase().insert(TB_NAME,+ DishMode.ds_cover+ text,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/sql/sqlite/11242.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
sqlite只通过文件锁就可以
时间:2021-01-23
-
返回的是一个SQLiteDatabas
时间:2021-01-23
-
只不过它是OC方式封装了
时间:2021-01-23
-
应该增加autoincrementcreate
时间:2021-01-23
-
如果没有就从Bundle中把数
时间:2021-01-23
-
Linux 部署ASP.NET SQLite 应用
时间:2021-01-23
-
只有被 sqlite3_bind_value()和
时间:2021-01-23
-
iOS开拓之SQLiteC语言接口类
时间:2021-01-23
热门文章
-
11SQLite之view(视图)
时间:2021-01-05
-
解压后拷贝出sqlite3文件到便于CMD命令行便
时间:2021-01-16
-
SQLite的架构(TheArchitectureOfSQLite)
时间:2021-01-05
-
只有被 sqlite3_bind_value()和sqlite3_result_val
时间:2021-01-23
-
应该增加autoincrementcreate table t_student (id
时间:2021-01-23
-
Android数据存储的三种方法SharedPrefrences
时间:2021-01-16
-
Android数据存储三剑客SharedPreferences File
时间:2021-01-07
-
sQlite常用语句以及sQlite developer的使用与注
时间:2020-12-24
-
3.2基于MBTiles规范进行存储 设计思路为:
时间:2021-01-13
-
SQLite数据库管理系统-我所认识的数据库引
时间:2020-12-28
