Android_SqLite数据库的创建与使用

【Android-SQLite】创建数据库 在学习sqlite的时候总结了SQLite创建数据库时的相关步骤: 写一个子类继承SQLiteOpenHelper,实现SQLiteOpenHelper中的方法,并创建一个构造方法 创建该子类对象,调用 getReadableDatabase() 或 getWriteabeleDatabase() 方法即可创建数据库 ———————————————————————————————————————... 阅读详情

一:数据库的创建:DBHelper

public class DBHelper extends SQLiteOpenHelper {

    private static final int VERSION = 1;
    private static String DB_NAME = "_name.db";
   
    private String CREATE_TABLE_PERSONS = "create table persons(_id integer primary key,prohibition integer,caseId integer,user_id integer, case_member_id integer,truename text,sex integer,mobile text," +
            "occupation text,birthday text,paper_type integer,paper_num text,employer text,address text,role integer," +
            "relation_member_id integer,type_name text,licence_type text,licence_num text,hxId text)";
   

    public DBHelper(Context context) {
        super(context, SPUtil.getInstance(context).getUserId() + DB_NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(CREATE_TABLE_PERSONS);
      
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      
        db.execSQL("drop table if exists persons");     
       
        db.execSQL(CREATE_TABLE_PERSONS);
       
    }

    public DBHelper instance;

    public void closeDB() {
        super.close();
    }
}

二:建立工具类PersonDao

public class PersonDao {
    private static final String TAG = "PersonDao";
    Context context;
    SQLiteDatabase db;

    public PersonDao(Context context) {
        this.context = context.getApplicationContext();
        //再此自动创建表
        db = new DBHelper(context).getWritableDatabase();
    }

    public void updateOrInsert(Person person, String caseId) {
        ContentValues values = new ContentValues();
        values.put("caseId", caseId);
        values.put("case_member_id", person.getCase_member_id());
        values.put("truename", person.getTruename());
        values.put("sex", person.getSex());
        values.put("mobile", person.getMobile());
        values.put("occupation", person.getOccupation());
        values.put("birthday", person.getBirthday());
        values.put("paper_type", person.getPaper_type());
        values.put("paper_num", person.getPaper_num());
        values.put("employer", person.getEmployer());
        values.put("address", person.getAddress());
        values.put("role", person.getRole());
        values.put("relation_member_id", person.getRelation_member_id());
        values.put("type_name", person.getType_name());
        values.put("licence_type", person.getLicence_type());
        values.put("licence_num", person.getLicence_num());
        values.put("user_id", person.getUser_id());
        values.put("prohibition", person.getProhibition());
        values.put("hxId", person.getHxId());

        int r = db.update("persons", values, "caseId=? and case_member_id=?", new String[]{caseId, person.getCase_member_id() + ""});
        if (r > 0) {
            L.e("person更新成功:" + values);
            db.close();
        } else {
            values.put("prohibition", 1);
            long x = db.insert("persons", null, values);
            if (x > -1) {
                L.e("person插入成功:" + values);

            }
            db.close();
        }
    }

    public Person queryOnePerson(String caseId, String user_id) {
        Person person = null;
        Cursor cursor = db.query("persons", null, "caseId=? and user_id=?", new String[]{caseId, user_id}, null, null, null);
        while (cursor.moveToNext()) {
            person = new Person();
            person.setCase_member_id(cursor.getInt(cursor.getColumnIndex("case_member_id")));
            person.setTruename(cursor.getString(cursor.getColumnIndex("truename")));
            person.setSex(cursor.getInt(cursor.getColumnIndex("sex")));
            person.setMobile(cursor.getString(cursor.getColumnIndex("mobile")));
            person.setOccupation(cursor.getString(cursor.getColumnIndex("occupation")));
            person.setBirthday(cursor.getString(cursor.getColumnIndex("birthday")));
            person.setPaper_type(cursor.getInt(cursor.getColumnIndex("paper_type")));
            person.setPaper_num(cursor.getString(cursor.getColumnIndex("paper_num")));
            person.setEmployer(cursor.getString(cursor.getColumnIndex("employer")));
            person.setAddress(cursor.getString(cursor.getColumnIndex("address")));
            person.setRole(cursor.getInt(cursor.getColumnIndex("role")));
            person.setRelation_member_id(cursor.getInt(cursor.getColumnIndex("relation_member_id")));
            person.setType_name(cursor.getString(cursor.getColumnIndex("type_name")));
            person.setLicence_type(cursor.getString(cursor.getColumnIndex("licence_type")));
            person.setLicence_num(cursor.getString(cursor.getColumnIndex("licence_num")));
            person.setUser_id(cursor.getInt(cursor.getColumnIndex("user_id")));
            person.setProhibition(cursor.getInt(cursor.getColumnIndex("prohibition")));
        }
        cursor.close();
        return person;
    }

    public ArrayList<Person> queryPersonByCaseId(String case_id) {//这个地方有bug,这样查询会查询出来很多个person,并且每个person会在不同的案件中有不同的身份
        Cursor cursor = db.query("persons", null, "caseId=?", new String[]{case_id}, null, null, null);
        System.out.println("查询数据库" + cursor.toString());
        ArrayList<Person> personsList = new ArrayList<>();
        while (cursor.moveToNext()) {
            System.out.println("查询数据库666" + cursor.toString());
            Person person = new Person();
            person.setCase_member_id(cursor.getInt(cursor.getColumnIndex("case_member_id")));
            person.setTruename(cursor.getString(cursor.getColumnIndex("truename")));
            person.setSex(cursor.getInt(cursor.getColumnIndex("sex")));
            person.setMobile(cursor.getString(cursor.getColumnIndex("mobile")));
            person.setOccupation(cursor.getString(cursor.getColumnIndex("occupation")));
            person.setBirthday(cursor.getString(cursor.getColumnIndex("birthday")));
            person.setPaper_type(cursor.getInt(cursor.getColumnIndex("paper_type")));
            person.setPaper_num(cursor.getString(cursor.getColumnIndex("paper_num")));
            person.setEmployer(cursor.getString(cursor.getColumnIndex("employer")));
            person.setAddress(cursor.getString(cursor.getColumnIndex("address")));
            person.setRole(cursor.getInt(cursor.getColumnIndex("role")));
            person.setRelation_member_id(cursor.getInt(cursor.getColumnIndex("relation_member_id")));
            person.setType_name(cursor.getString(cursor.getColumnIndex("type_name")));
            person.setLicence_type(cursor.getString(cursor.getColumnIndex("licence_type")));
            person.setLicence_num(cursor.getString(cursor.getColumnIndex("licence_num")));
            person.setUser_id(cursor.getInt(cursor.getColumnIndex("user_id")));
            person.setProhibition(cursor.getInt(cursor.getColumnIndex("prohibition")));
            person.setHxId(cursor.getString(cursor.getColumnIndex("hxId")));
            personsList.add(person);
        }
        cursor.close();
        db.close();
        return personsList;
    }

    public Person queryPersonByHXid(String caseId,String hxId) {
        Person person = null;
        Cursor cursor = db.query("persons", null, "caseId=? and hxId=?", new String[]{caseId,hxId}, null, null, null);
        while (cursor.moveToNext()) {
            person = new Person();
            person.setCase_member_id(cursor.getInt(cursor.getColumnIndex("case_member_id")));
            person.setTruename(cursor.getString(cursor.getColumnIndex("truename")));
            person.setSex(cursor.getInt(cursor.getColumnIndex("sex")));
            person.setMobile(cursor.getString(cursor.getColumnIndex("mobile")));
            person.setOccupation(cursor.getString(cursor.getColumnIndex("occupation")));
            person.setBirthday(cursor.getString(cursor.getColumnIndex("birthday")));
            person.setPaper_type(cursor.getInt(cursor.getColumnIndex("paper_type")));
            person.setPaper_num(cursor.getString(cursor.getColumnIndex("paper_num")));
            person.setEmployer(cursor.getString(cursor.getColumnIndex("employer")));
            person.setAddress(cursor.getString(cursor.getColumnIndex("address")));
            person.setRole(cursor.getInt(cursor.getColumnIndex("role")));
            person.setRelation_member_id(cursor.getInt(cursor.getColumnIndex("relation_member_id")));
            person.setType_name(cursor.getString(cursor.getColumnIndex("type_name")));
            person.setLicence_type(cursor.getString(cursor.getColumnIndex("licence_type")));
            person.setLicence_num(cursor.getString(cursor.getColumnIndex("licence_num")));
            person.setUser_id(cursor.getInt(cursor.getColumnIndex("user_id")));
            person.setProhibition(cursor.getInt(cursor.getColumnIndex("prohibition")));
            person.setHxId(cursor.getString(cursor.getColumnIndex("hxId")));
        }
        cursor.close();
        db.close();
        return person;
    }

    public ArrayList<Person> queryPersonsByCaseId(String caseId) {
        ArrayList<Person> list = new ArrayList<>();
        Cursor cursor = db.query(true, "persons", null, "caseId=?", new String[]{caseId}, null, null, null, null);
        Person person;
        while (cursor.moveToNext()) {
            person = new Person();
            person.setCase_member_id(cursor.getInt(cursor.getColumnIndex("case_member_id")));
            person.setTruename(cursor.getString(cursor.getColumnIndex("truename")));
            person.setSex(cursor.getInt(cursor.getColumnIndex("sex")));
            person.setMobile(cursor.getString(cursor.getColumnIndex("mobile")));
            person.setOccupation(cursor.getString(cursor.getColumnIndex("occupation")));
            person.setBirthday(cursor.getString(cursor.getColumnIndex("birthday")));
            person.setPaper_type(cursor.getInt(cursor.getColumnIndex("paper_type")));
            person.setPaper_num(cursor.getString(cursor.getColumnIndex("paper_num")));
            person.setEmployer(cursor.getString(cursor.getColumnIndex("employer")));
            person.setAddress(cursor.getString(cursor.getColumnIndex("address")));
            person.setRole(cursor.getInt(cursor.getColumnIndex("role")));
            person.setRelation_member_id(cursor.getInt(cursor.getColumnIndex("relation_member_id")));
            person.setType_name(cursor.getString(cursor.getColumnIndex("type_name")));
            person.setLicence_type(cursor.getString(cursor.getColumnIndex("licence_type")));
            person.setLicence_num(cursor.getString(cursor.getColumnIndex("licence_num")));
            person.setUser_id(cursor.getInt(cursor.getColumnIndex("user_id")));
            person.setProhibition(cursor.getInt(cursor.getColumnIndex("prohibition")));
            person.setHxId(cursor.getString(cursor.getColumnIndex("hxId")));
            if (!list.contains(person))
                list.add(person);
        }
        cursor.close();
        db.close();
        return list;
    }

    public void deleteByCaseId(String caseId) {
        db.delete("persons", "caseId=?", new String[]{caseId});
    }

    public String getPersonRole(String caseId, String case_member_id) {
        String role = null;
        String sql = "select role from persons where caseId='" + caseId + "' and case_member_id='" + case_member_id + "'";
        L.e("sql->" + sql);
        Cursor cursor = db.query("persons", new String[]{"role"}, "caseId=? and case_member_id=?", new String[]{caseId, case_member_id}, null, null, null);
        while (cursor.moveToNext()) {
            role = cursor.getString(0);
        }
        cursor.close();
        db.close();
        return role;
    }

    public void updatePersonPermision(String caseId, String userId, int permision) {
        ContentValues values = new ContentValues();
        values.put("prohibition", permision);
        int r = db.update("persons", values, "caseId=? and user_id=?", new String[]{caseId, userId});
        L.e("PersonDao", "更新结果->" + r);
        db.close();
    }

    public void release() {
        if (db != null) {
            db.close();
        }
    }
}


三:person的bean类

package com.zjtp.dyhtj.anjian.modle.beans;

/**
 * 人员实体类(注重关注于应用的业务逻辑)
 * Created by Administrator on 2017/7/17.
 */

public class Person {

    public void Person() {
    }


    public static final int ROLE_TJY = 0;
    public static final int ROLE_YG = 1;
    public static final int ROLE_YGDLR = 2;
    public static final int ROLE_BG = 3;
    public static final int ROLE_BGDLR = 4;
    public static final int ROLE_BGF = 6;
    public static final int ROLE_YGF = 7;

    /**
     * case_member_id : 67
     * truename : 李丰君代理
     * sex : 1
     * mobile : 13311167851
     * occupation :
     * birthday : 1992-11-11
     * paper_type : 1
     * paper_num : 371322199211110016
     * employer : 律金汇
     * address : 测试
     * role : 1
     * relation_member_id : 66
     * type_name : 自然人
     * licence_type :
     * licence_num :
     */

    public String hxId;
    public int user_id;
    public int prohibition;
    public int case_member_id;
    public String truename;
    public int sex;
    public String mobile;
    public String occupation;
    public String birthday;
    public int paper_type;
    public String paper_num;
    public String employer;
    public String address;
    public int role;
    public int relation_member_id;
    public String type_name;
    public String licence_type;
    public String licence_num;

    public String getHxId() {
        return hxId;
    }

    public void setHxId(String hxId) {
        this.hxId = hxId;
    }

    public int getProhibition() {
        return prohibition;
    }

    public void setProhibition(int prohibition) {
        this.prohibition = prohibition;
    }

    public int getUser_id() {
        return user_id;
    }

    public void setUser_id(int user_id) {
        this.user_id = user_id;
    }

    public int getCase_member_id() {
        return case_member_id;
    }

    public void setCase_member_id(int case_member_id) {
        this.case_member_id = case_member_id;
    }

    public String getTruename() {
        return truename;
    }

    public void setTruename(String truename) {
        this.truename = truename;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getOccupation() {
        return occupation;
    }

    public void setOccupation(String occupation) {
        this.occupation = occupation;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public int getPaper_type() {
        return paper_type;
    }

    public void setPaper_type(int paper_type) {
        this.paper_type = paper_type;
    }

    public String getPaper_num() {
        return paper_num;
    }

    public void setPaper_num(String paper_num) {
        this.paper_num = paper_num;
    }

    public String getEmployer() {
        return employer;
    }

    public void setEmployer(String employer) {
        this.employer = employer;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getRole() {
        return role;
    }

    public void setRole(int role) {
        this.role = role;
    }

    public int getRelation_member_id() {
        return relation_member_id;
    }

    public void setRelation_member_id(int relation_member_id) {
        this.relation_member_id = relation_member_id;
    }

    public String getType_name() {
        return type_name;
    }

    public void setType_name(String type_name) {
        this.type_name = type_name;
    }

    public String getLicence_type() {
        return licence_type;
    }

    public void setLicence_type(String licence_type) {
        this.licence_type = licence_type;
    }

    public String getLicence_num() {
        return licence_num;
    }

    public void setLicence_num(String licence_num) {
        this.licence_num = licence_num;
    }

    @Override
    public String toString() {
        return "Person{" +
                "hxId='" + hxId + '\'' +
                ", user_id=" + user_id +
                ", prohibition=" + prohibition +
                ", case_member_id=" + case_member_id +
                ", truename='" + truename + '\'' +
                ", sex=" + sex +
                ", mobile='" + mobile + '\'' +
                ", occupation='" + occupation + '\'' +
                ", birthday='" + birthday + '\'' +
                ", paper_type=" + paper_type +
                ", paper_num='" + paper_num + '\'' +
                ", employer='" + employer + '\'' +
                ", address='" + address + '\'' +
                ", role=" + role +
                ", relation_member_id=" + relation_member_id +
                ", type_name='" + type_name + '\'' +
                ", licence_type='" + licence_type + '\'' +
                ", licence_num='" + licence_num + '\'' +
                '}';
    }
}

四:插入数据库:

 //把原告代理人信息存入数据库
                        Person person = new Person();
                        person.setCase_member_id(accuserAgentBean.getCase_member_id());
                        person.setTruename(accuserAgentBean.getTruename());
                        person.setSex(accuserAgentBean.getSex());
                        person.setMobile(accuserAgentBean.getMobile());
                        person.setOccupation(accuserAgentBean.getOccupation());
                        person.setBirthday(accuserAgentBean.getBirthday().toString());
                        person.setPaper_type(accuserAgentBean.getPaper_type());
                        person.setPaper_num(accuserAgentBean.getPaper_num());
                        person.setEmployer(accuserAgentBean.getEmployer());
                        person.setAddress(accuserAgentBean.getAddress());
                        person.setRole(accuserAgentBean.getRole());
                        person.setRelation_member_id(accuserAgentBean.getRelation_member_id());
                        person.setType_name(accuserAgentBean.getTruename());
                        person.setLicence_type(accuserAgentBean.getLicence_type());
                        person.setLicence_num(accuserAgentBean.getLicence_num());
                        person.setUser_id(accuserAgentBean.getUser_id());
                        person.setHxId(accuserAgentBean.getHx_account());
                        PersonDao personDao = new PersonDao(getActivity());
                        person.setProhibition(0);
                        personDao.updateOrInsert(person, case_id + "");

五:查询数据库:

  //查询表里是否有数据
  final ArrayList<Person> persons = personDao.queryPersonsByCaseId(case_id + "");
  if (persons.size() != 0) {
    //有数据
   }


DBHelper数据库工具类 连接数据库工具类,只需要改变其中的数据库名称和连接密码就可以使用! 立即下载

相关推荐

基于Android的SQLite数据库操作Demo

基于Android的SQLite数据库操作Demo

Android SQLite数据库创建和使用实战(一)

转载地址:http://blog.csdn.net/yanbober/article/details/20688273 Android SQLiteSQLiteOpenHelper数据库databasecursor 废话不多说,Android撑死算个入门选手,刚好有点时间,随之倒腾整理下Android数据库操作。码农只需要代码和原理,理论从代码中自己感悟。小二,上代码,弄。

qq_20816947的博客 830

Python3.11安装fairseq避坑指南:解决dataclasses兼容性问题(附详细代码修改)

本文详细解析了在Python 3.11环境下安装Fairseq时因dataclasses模块规则变更导致的安装失败问题。通过定位核心配置文件,将`default=SomeConfig()`修改为`default_factory=SomeConfig`,并调整依赖版本,提供了从源码修改到环境验证的完整解决方案,确保Fairseq顺利运行。

weixin_29098367的博客 495

android sqlite 数据库创建,在android中创建SQLite数据库

好的例子是here。try {myDB = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);/* Create a Table in the Database. */myDB.execSQL("CREATE TABLE IF NOT EXISTS "+ TableName+ " (Field1 VARCHAR, Field...

weixin_29737207的博客 561

ESP32S3开发板玩转多语言AI对话:小智语音机器人粤语/日语/韩语实测

本文基于正点原子ESP32S3开发板,实测了“小智AI”语音机器人的多语言对话能力。项目巧妙整合云端AI与嵌入式硬件,实现了对粤语、日语、韩语等语言的实时识别与合成,为开发者和爱好者提供了一个低成本、可玩性高的跨语言人机交互开发平台。

h9j8k7l6m5n的博客 537

3D识别建模 — 基于ReconstructMe和EAGLE EYES SCANNER的实现

3D实体识别建模,作为3D打印反向工程的一个重要环节,今天就让我们利用ReconstructMe和EAGLE EYES SCANNER来了解一下。 第一步、软件和硬件准备就绪 ReconstructMe下载并安装 http://reconstructme.net/?wpdmdl=160 EAGLE EYES SCANNER直接将相应USB插入电脑接口即OK,之后在    中点击搜索“设备管理...

qq_40013290的博客 881

Android 使用SQLite数据库

Android 往SQLite数据库中存放类,更简单的使用数据库存储功能

qq_38174131的博客 6525

深入STM32 USB OTG FS:从官方MSC例程到实战双存储设备移植全记录

本文详细解析了STM32 USB OTG FS在双存储设备开发中的实战应用,从协议栈底层机制到SD卡/SPI Flash同步挂载的实现。通过优化SDIO接口和SPI Flash驱动,结合USB MSC类的关键实现,提供了完整的解决方案和性能优化策略,适合嵌入式开发者参考。

weixin_28366475的博客 368

android SQLite编程详解

SQLite 数据库功能非常强大,使用起来也非常方便,SQLite数据库的一般操作包括:创建数据库、打开数据库、创建表、向表中添加数据、从表中删除数据、修改表中的数据、关闭数据库、删除指定表、删除数据库和查询表中的某条数据。下面我们分别来学习这些基本操作。 1.创建和打开数据库 在Android 中创建和打开一个数据库都可以使用openOrCreateDatabase 方...

低级写手 我自由了 199

Oracle Scheduler任务故障诊断 实战指南

当基础环境无异常时,需聚焦任务本身的配置与状态。定义(JOB)→ 调度(SCHEDULE)→ 执行(SLAVE进程)→ 日志(LOG),每个环节都可能存在卡点。Oracle Scheduler任务的“隐性故障”看似棘手,实则是环境配置、资源竞争、时间逻辑等问题的集中体现。通过本文的诊断工具和排查思路,你可以构建从“基础环境→任务配置→执行链路→日志追踪”的全维度分析体系,让每一个“消失”的任务都无所遁形。

Nuzbb的博客 1073

水与光的奇妙“切割之舞”:水导激光切割技术探秘

水导激光切割技术的诞生,是材料加工领域不断追求高精度、高质量加工的成果。传统激光切割技术在加工过程中,材料会因瞬间高温而产生热变形、热影响区大以及切割面粗糙等问题,这些弊端在对一些高精度、热敏性材料的加工中尤为突出 ,迫切需要一种新的技术来克服这些难题。水导激光切割技术的起源可以追溯到 20 世纪 80 年代。1986 年,德国公司 Aesculap-Werke AG 首次提出了将水流引入激光切割过程的创新想法,并制造出首代水导激光设备。不过,当时的技术尚处于雏形阶段,仅仅是在光纤出口添加了一小柱水流,激光

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1673

android 中sqlite数据库,Android中SQLite数据库基础操作

Android中的数据库存储是直接使用了SQLite。在Android应用中创建数据库后数据库文件是存储在/data/ data/应用包名/databases/下。重要API接口在Android中使用到SQLite会涉及到以下三个类或接口,分别如下:SQLiteOpenHelperSQLiteOpenHelper 构造方法,一般传递一个要创建的数据库名称name参数。主要的方法如下:onCreat...

weixin_28685487的博客 2293

〔重庆理工大学〕计算机组成原理课设报告--16位单周期CPU设计

本课程设计的实验平台为Altera Quartus II 软件和Altera Cyclone V Starter 工具箱。(1)Cyclone V是Altera FPGAs家族的一类,它面向低功耗应用。Cyclone V GX 5CGXFC5C6F27C7N 芯片有不同的转换器,按钮,LED灯,七段显示器,HDMI接口,SD卡读卡器以及其他链接等。Cyclone V GX 5CGXFC5C6F27C7N是Starter工具箱的重要组件。(2)测试台包含在测设备(DUT)和用于仿真的模拟输入。

Pretty Boy Fox的博客 1066

安卓获取本地时间插入sqlite_Android 本地SQLite创建database

Android 可以在本地创建数据库-SQLite, 是一种轻型的数据库,是设计目标是嵌入式,具有占用资源非常低等特点创建数据库和数据表:DatabaseHelper.javapublic class DatabaseHelper extends SQLiteOpenHelper {// Logcat tagprivate static final String LOG = "DatabaseHe...

weixin_39593498的博客 197

热力学仿真软件:ANSYS CFX_(15).旋转机械仿真

创建旋转域在中选择需要设置为旋转域的区域。选择选项。设置旋转速度在设置中,指定旋转速度(单位为弧度/秒)。也可以选择选项,并输入具体值。设置旋转轴在设置中,指定旋转轴的方向和位置。通常旋转轴的方向可以使用单位向量来表示,例如[0, 0, 1]表示沿Z轴旋转。旋转轴的位置可以通过指定一个点的坐标来确定,例如[0, 0, 0]表示旋转轴通过原点。旋转机械的仿真在ANSYS CFX中是一个复杂但重要的过程。

kkchenjj的博客 1158

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Android数据库SQLite的创建方法

Android数据库SQLite的创建方法 tags:android技术 新一个数据库创建的类 新建一个工程,在工程下新建一个类。代码如下: 类名为NotesDB根据你的需要来取名, 继承于SQLiteOpenHelper 创建构造函数public NotesDB(Context context) 重写onCreate和onUpgrade方法。 public class NotesDB exten...

weixin_44880903的博客 1094

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

android工程如何创建数据库,安卓项目-利用Sqlite数据库,开发新闻发布系统

本教程致力于程序员可以快速的学习安卓移动端手机开发。适合于已经习得一种编程语言的同仁。更多志同道合,想要学习更多编程技术的大神们。小弟不才,麻烦关注一下我的今日头条号-做全栈攻城狮。Sqlite数据库:Sqlite数据库是在安卓中使用较广泛的数据库。其为简单、轻巧的Sql类文件型数据库。因以简单的文本形式保存,所以安全性不是很高。只要拿到sqlite数据库文件就可以得到数据。所以这就决定了sqli...

weixin_42501974的博客 647

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

android 数据库 创建不成功你,Android SQLite创建的数据库,但无法找到表

因此,我试图从我的数据库表中取数据,请你检查一下,看看你是否可以发现错误?Android SQLite创建的数据库,但无法找到表SQLiteDatabase db = SQLiteDatabase.openDatabase(DB_PATH, null,SQLiteDatabase.OPEN_READONLY);Cursor cursor = db.query(TABLE_CLASSES, new ...

weixin_35677043的博客 1462

android sqlite 数据库创建,Android下创建一个SQLite数据库(示例代码)

数据库:SQLite(轻量级,嵌入式的数据库)大量的相似结构的数据的储存,快速的查询。特殊的文件(按照一定的格式生成)数据库的创建创建文件1.声明文件对象,文件是不会被创建出来的。File file = new File("文件名称");2.写文件(文件才会被创建出来)FileOutputStream fos = new FileOutputStream(file);fos.write("hdah...

weixin_32516271的博客 1451

安卓SQLite数据库创建与共享

安卓用于创建数据库提供类SQLiteOpenHelper;由于此类是抽象类,需要创建自定义(此处用MySQLiteOpenHelper)类继承SQLiteOpenHelper后,需要复写oncreate,onUpgrade抽象方法分别用于创建,升级数据库逻辑;SQLiteOpenHelper有非常重要的两个实例方法(getReadableDatabase(),getWritableDatabases

qq_27963193的博客 1882

Android studio 连接SQLite数据库 +创建数据库+创建数据库表

Android studio 连接使用数据库 SQLite 傻瓜式教程 详细教程 有图有解释 再说学不废 那就回家放牛吧(再提醒你别把牛放丢啦)

hjjshua的博客 7万+

Android连载33-在android内创建SQLite数据库

一、创建SQLite数据库在android内部 SQLiteOpenHelper类介绍: 抽象类,内含两个抽象方法:onCreate()和onUpgrade(),还有两个实例方法:getReadableDatabase()和getWritableDatabase() 这两个实例方法都可以创建或者打开一个现有的数据库(如果数据库已经存在那么直接打开,否则会先创建一个新的数据库),并且返回一个可以对数据库进行读写操作的对象。 不同的是,当数据库不可以写入的时候(如磁盘空间已经满了)getReadableDat

weixin_44630050的博客 375

android: SQLite创建数据库

SQLite 是一款轻量级的关系型数据库,它的运算速度非常快, 占用资源很少,通常只需要几百 K 的内存就足够了,因而特别适合在移动设备上使用。SQLite 不仅支持标准的 SQL 语法,还遵循了数据

dearbaba_8520的博客 749

Android-SQLite—数据库创建

Android-SQLite—数据库创建 1.创建 usersDatabaseHelper.java 继承 SQLiteOpenHelper方法 package com.example.androidsqlite1; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatab...

坚持就是胜利的博客 694

Android 创建SQLite 数据库并查看创建结果

SQLite 是关系型数据库,与我之前学javaEE 时接触的Orancle、MySql数据库没有太大区别,只是SQLite 是轻量级的数据库,而且一般给变量声明类型和限定长度没有作用,不过也有例外(当变量为主键)。

sinat_29398599的博客 1万+

Android Studio中Sqlite数据库的创建及升级

今天学习了如何建立Sqlite数据库 MainActivity package com.example.a92133.databasedemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivi...

weixin_44754752的博客 1623
上一篇: Android_Okgo网络请求增加自定义的DialogCallBack
下一篇: Android_小米魅族测试时提示INSTALL_FAILED_USER_RESTRICTED错误的问题
ParkSiHoo_
博客等级 码龄10年 20粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值