0

我没有看到我的代码有任何错误,我浏览了同样问题的问题但我无法解决它,我尝试将 sql 版本从 1 升级到 2,但仍然出现同样的错误。

我的代码有什么问题吗?

public String place_ID = "id";
public String place_LAT = "LAT";
public String place_LNG = "LNG"; 
public String place_name = "name";
public String place_number = "number";
public String place_city = "city";
public String place_country = "country";
public String place_street = "street";
public String place_smallDesc = "smallDesc";
public String place_bigDesc = "bigDesc";
public String place_site = "site";
public String place_category = "category";
public String place_imageName ="image";
public String place_rank = "rank";

final static String PASS = "testPass";
final static String db_Name = "placesManager";
final static String DBTABLE_NAME_STRING = "places";
public DatabaseHelper(Context context) {
    super(context, db_Name,null,2);
    // TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
String createDBQuery = "CREATE TABLE " + DBTABLE_NAME_STRING + "("
        + place_ID + " INTEGER PRIMARY KEY," + place_LAT + " REAL,"
        + place_name + " TEXT,"  + place_number + " TEXT,"
        + place_city + " TEXT,"  + place_country + " TEXT,"
        + place_street + " TEXT" + place_smallDesc + " TEXT,"
                + place_site + " TEXT" + place_category + " TEXT,"
                + place_imageName + " TEXT"+ place_rank + " INTEGER " + ")";
    db.execSQL(createDBQuery);
}
public void AddPlaces(ArrayList<Place> placesList)
{
    SQLiteDatabase db = this.getWritableDatabase(PASS);
    ContentValues cValues = new ContentValues();
    Log.d("MyTag","inserting");
    for(int i = 0;i<placesList.size();i++)
    {
    cValues.put(place_ID, placesList.get(i).ID);
    cValues.put(place_LAT, placesList.get(i).LAT);
    cValues.put(place_LNG, placesList.get(i).LNG);
    cValues.put(place_name, placesList.get(i).name);
    cValues.put(place_number, placesList.get(i).number);
    cValues.put(place_city, placesList.get(i).city);
    cValues.put(place_ID, placesList.get(i).ID);
    cValues.put(place_street, placesList.get(i).street);
    cValues.put(place_smallDesc, placesList.get(i).smallDesc);
    cValues.put(place_site, placesList.get(i).site);
    cValues.put(place_category, placesList.get(i).category);
    cValues.put(place_imageName, placesList.get(i).imageName);
    cValues.put(place_rank, placesList.get(i).rating);

    db.insert(DBTABLE_NAME_STRING, null, cValues);
    }
    Log.d("MyTag","done inserting");
    db.close();
}
4

1 回答 1

4

里面onCreate你有:

 + place_street + " TEXT" + place_smallDesc + " TEXT,"

应该如下所示(遗漏冒号),由于冒号遗漏,合并和表的列名将与您假设的完全不同。

 + place_street + " TEXT, " + place_smallDesc + " TEXT,"
于 2012-11-16T22:54:44.397 回答