Android 数据库操作
2010-05-31 14:52:00 来源:WEB开发网上面是个人封装的一个比较简单的数据库:
都是用的数据库指定创建的,个人认为这样做起来比较的方便,下面将为大家说的是如何根据某种条件来从数据库中提取数据
view plaincopy to clipboardprint?
StringBuilder builder = new StringBuilder ();
builder.append("图像名称: "+list[position]+" ");
String sql = String.format("select * from pvs_sql where name='%s'", list[position]);
Cursor cursor = dataBase.getCursor(sql);//游标到达指定的数据行处
if(cursor != null && cursor.getCount()!=0)
{
cursor.moveToFirst();
int colNum = cursor.getColumnIndex("jingdu");
builder.append("经度:"+cursor.getInt(colNum)+" ");//提取经度信息
colNum = cursor.getColumnIndex("weidu");
builder.append("纬度:"+cursor.getInt(colNum)+" ");//提取纬度信息
colNum = cursor.getColumnIndex("address");
builder.append("拍照地点: "+cursor.getString(colNum)+" ");//提取拍照地点的信息
colNum = cursor.getColumnIndex("time");
builder.append("拍照时间:"+cursor.getString(colNum));
}
else
{
builder.append("获取拍照信息失败");
}
StringBuilder builder = new StringBuilder ();
builder.append("图像名称: "+list[position]+" ");
String sql = String.format("select * from pvs_sql where name='%s'", list[position]);
Cursor cursor = dataBase.getCursor(sql);//游标到达指定的数据行处
if(cursor != null && cursor.getCount()!=0)
{
cursor.moveToFirst();
int colNum = cursor.getColumnIndex("jingdu");
builder.append("经度:"+cursor.getInt(colNum)+" ");//提取经度信息
colNum = cursor.getColumnIndex("weidu");
builder.append("纬度:"+cursor.getInt(colNum)+" ");//提取纬度信息
colNum = cursor.getColumnIndex("address");
builder.append("拍照地点:
更多精彩
赞助商链接