android 访问SQLite
16lz
2021-12-04
static SQLiteDatabase sld;sld=SQLiteDatabase.openDatabase("/data/data/com.bn.rcgl/myDb", null, SQLiteDatabase.OPEN_READWRITE|SQLiteDatabase.CREATE_IF_NECESSARY);String sql="create table if not exists type(tno integer primary key,tname varchar2(20));";sld.execSQL(sql);Cursor cursor=sld.query("type", null, null, null, null, null, "tno");int count=cursor.getCount();if(count==0)//如果是第一次运行程序,自动创建3个缺省类型{for(int i=0;i<father.defultType.length;i++){sql="insert into type values("+i+",'"+father.defultType[i]+"')";sld.execSQL(sql);}cursor=sld.query("type", null, null, null, null, null, "tno");count=cursor.getCount();}alType.clear();while(cursor.moveToNext()){alType.add(cursor.getString(1));}sld.close();cursor.close();
http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CITy7klxxrJ35Nnc0biuQdjfLEM8uzKatFDeyBoh7SE6dSqDdi3pWAEfxisctECTUhdYJJ15S7iGFsMqZxql9zwMmTDicnHMwuOhc3p3IZUCd6h4%2Bs%3D
更多相关文章
- android 通过代码创建页面组件
- Android之创建实时文件夹
- Android欢迎界面的创建方法
- Android中使用 listView 绘制表格
- Android(安卓)- ToDoList(fragment) 详解
- Android运行报错:Error: Static interface methods are only supp
- Android中创建文件夹和文件的操作
- 删除Android包
- [原]运行编译好的Android模拟器