sqlite插入数据不报错,但是表中无数据
「已注销」 2016-11-12 03:13:18 /**
* 将County实例存储到数据库
*/
public void saveCounty(County county){
if(county != null){
ContentValues values = new ContentValues();
values.put("county_name", county.getCountyName());
values.put("county_code", county.getCountyCode());
values.put("city_id", county.getCityId());
//String slq = "insert into County(county_name,county_code,city_id) values('"
//+county.getCountyName()+"',"+county.getCountyCode()+','+county.getCityId()+")";
//county对象Name,Id,CityId都有值,可是就是插入不进去,也不报错。自己用命令却可以给数据库添加进去数据
db.insert("County", null, values);
}
}
/**
* County县表创建
*/
public static final String CREATE_COUNTY = "create table County ("
+ "id integer primary key autoincrement,"
+ "county_name text,"
+ "county_code text,"
+ "city_id integer)";
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE_CITY);
db.execSQL(CREATE_COUNTY);
db.execSQL(CREATE_PROVINCE);
}
我是做的天气,从服务器获取的省份,城市,和县的代号和城市然后存储到数据库。省份表和城市表按照这种方法都可以,唯独县表无法插入数据,logcat无报错