android 访问SQLite

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();


[url]http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CITy7klxxrJ35Nnc0biuQdjfLEM8uzKatFDeyBoh7SE6dSqDdi3pWAEfxisctECTUhdYJJ15S7iGFsMqZxql9zwMmTDicnHMwuOhc3p3IZUCd6h4%2Bs%3D[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值