数据库2
来源:互联网 发布:单片机at 编辑:程序博客网 时间:2024/05/18 01:41
edittext光标放在一开始:android:gravity="top" ;
光标放在指定的位置:edittext.setSelection(str.length());
数据库的增,删,改,查
myDataBase MyDataBase = new MyDataBase(ActivityAddBeiWangLu.this,
"kechengbiao", null, 2);
SQLiteDatabase db = myDataBase.getWritableDatabase();
//增加
ContentValues values = new ContentValues();
values.put("zuoye", zuoye);
values.put("shijian", shijian);
db.insert("beiWangLu", null, values);
//values.put("属性名",属性值);
//db.insert("表名“,null,值);
//修改
String str = "UPDATE beiWangLu SET zuoye='"+zuoye+"' WHERE _id=" + itemBeiWangLu.getId();
db.execSQL(str);
//其他操作也可直接像这样使用SQL语句进行操作
//查找
//db.query(String table, String[] columns, String selection,String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
Cursor cursor = db.query("ignorCourses",
new String[] { "name" }, null, null, null, null, null);
// 将数据全部加载到list中
while (cursor.moveToNext()) {
String name = cursor.getString(cursor
.getColumnIndex("name"));
list.add(name);
}
//删除
String x = list.get(position);
//db.delete(String table,String whereClause,String whereArgs);
db.delete("ignorCourses", "name=?", new String[] { x });
- 数据库-2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库2
- 数据库<2>
- 数据库2
- 数据库系统-- 2 关系数据库
- 数据库知识补充(2)---数据库查询优化
- 数据库战略高度解析(2) 数据库驱动程序
- 数据库学习笔记2-oracle 数据库锁
- win64位 安装python opencv
- Linux学习之路-02-Ubuntu系统关闭独显+省电降温设置
- Matlab之print,fprint,fscanf,disp函数
- 第2章 Python基础语法--Hello python
- UNIX环境高级编程——信号
- 数据库2
- FastJson---高性能JSON开发包
- 1209 - The MySQL server is running with the --read-only option so it cannot execute this statement
- 理论: 图论(6): 单源赋值图最短路径
- 使用hive访问elasticsearch的数据
- 一起talk C栗子吧(第八十六回:C语言实例--使用信号进行进程间通信三)
- 第1章 Python简介
- leetcode之Bulb Switcher
- 大文件下载(暂停和恢复下载)