当前位置:网站首页>SQLite database
SQLite database
2022-07-23 21:10:00 【shuo277】
database
SQLite Light weight No configuration required localization
To borrow Class,DBHelper Inherit SQLiteOpenHelper
Implement two abstract methods onCreate() onUpgrade() Create a constructor with parameters
In the constructor Create database
stay onCreate() In the method , Create tables and insert data
Find the problem :
When the mobile phone is running , What is used to identify software ?
Package name
To operate a database
1. Create database

2. Create tables in the newly created database

The process of executing query statements
//1. Get database objects SQLiteDatabase db=dbHelper.getWritableDatabase(); //2. perform Put the result set in the vernier caliper Cursor cursor = db.rawQuery(sql, null); //3. Take out the results List<Userinfo> list=new ArrayList<>(); while (cursor.moveToNext()){ Userinfo userinfo=new Userinfo(); userinfo.setId(cursor.getInt(0)); userinfo.setUser(cursor.getString(1)); userinfo.setPwd(cursor.getString(2)); list.add(userinfo); } //4. Release resources cursor.close(); db.close();
perform increase 、 Delete 、 Changed process
1. Get database objects
SQLiteDatabase db=dbHelper.getWritableDatabase();
1. Executive action
String sql="delete from userinfo where id=?";
db.execSQL(sql,new String[]{"1"});
1. Release resources
db.close();
边栏推荐
- High numbers | calculation of double integral 3 | high numbers | handwritten notes
- 【Kernel】驱动开发学习之Platform平台总线模型
- TCP半连接队列和全连接队列(史上最全)
- 当我们在谈论陈春花和华为时,我们到底在讨论什么?
- Read the five flow indicators of R & D efficiency insight
- Is it safe to open a mobile stock account?
- Trial record of ModelBox end cloud collaborative AI development kit (rk3568) (II)
- 2022-7-23 12点 程序爱生活 小时线顶背离出现,保持下跌趋势,等待反弹信号出现。
- How to get the worker's hat? Where is the worker's helmet?
- Microservice architecture vs single service architecture [what can Huawei cloud service do in the microservice mode]
猜你喜欢
随机推荐
TCP半连接队列和全连接队列(史上最全)
《迷失》stray工人帽子获得方法 工人安全帽在哪里?
告诉我十大证券公司?请问网上开户安全么?
WinDbg实践--入门篇
221. Largest square ● &1277. Square submatrix with statistics all 1 ● ●
From which dimensions can we judge the quality of code? How to have the ability to write high-quality code?
高数下|二重积分的计算4|高数叔|手写笔记
信号的理解
当我们在谈论陈春花和华为时,我们到底在讨论什么?
【微信小程序】你了解小程序开发吗?
Today's sleep quality record 81 points
Major upgrade of openim - group chat reading diffusion model release group management function upgrade
现在完全不知道怎么同步
WinDbg practice -- Introduction
VLAN综合实验
Oom mechanism
[attack and defense world web] difficulty four-star 12 point advanced question: confusion1
Proof of green Tao theorem (1): preparation, notation and Gowers norm
Major optimization of openim - Message loading on demand, consistent cache, uniapp Publishing
Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]









