新人,请多关照
代码如下:
public mapEntity findMap(int id) {
SQLiteDatabase sd = this.getWritableDatabase();
Cursor cursor = sd.rawQuery(" select * from Tbl_Map where _id=?", new String[] {id+"" });
if (cursor.moveToNext()) {
mapEntity map = new mapEntity();
map.set_id(cursor.getInt(cursor.getColumnIndex(MAP_ID)));
map.setMapName(cursor.getString(cursor.getColumnIndex(MAPNAME)));
map.setMapArray(cursor.getString(cursor.getColumnIndex(MAPARRAY)));
map.setMapType(cursor.getString(cursor.getColumnIndex(MAPTYPE)));
map.setMapState(cursor.getString(cursor.getColumnIndex(MAPSTATE)));
return map;
}
cursor.close();
sd.close();
return null;
}public class mapEntity {
private int _id;
private String mapName;
private String mapArray;
private String mapType;
private String mapState;
.....
}
activity中调用
mapAdpter mapAdpter=new mapAdpter(context);
mapEntity en=mapAdpter.findMap(id);为啥查出来的是空指针呢。我写一个通过name查找的方法又找得到数据
有大神帮忙吗
不甚感激
代码如下:
public mapEntity findMap(int id) {
SQLiteDatabase sd = this.getWritableDatabase();
Cursor cursor = sd.rawQuery(" select * from Tbl_Map where _id=?", new String[] {id+"" });
if (cursor.moveToNext()) {
mapEntity map = new mapEntity();
map.set_id(cursor.getInt(cursor.getColumnIndex(MAP_ID)));
map.setMapName(cursor.getString(cursor.getColumnIndex(MAPNAME)));
map.setMapArray(cursor.getString(cursor.getColumnIndex(MAPARRAY)));
map.setMapType(cursor.getString(cursor.getColumnIndex(MAPTYPE)));
map.setMapState(cursor.getString(cursor.getColumnIndex(MAPSTATE)));
return map;
}
cursor.close();
sd.close();
return null;
}public class mapEntity {
private int _id;
private String mapName;
private String mapArray;
private String mapType;
private String mapState;
.....
}
activity中调用
mapAdpter mapAdpter=new mapAdpter(context);
mapEntity en=mapAdpter.findMap(id);为啥查出来的是空指针呢。我写一个通过name查找的方法又找得到数据
有大神帮忙吗
不甚感激
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货