这是我保存数据的类
public class Report {
public String report_title="";
public String report_descrption="";
public String report_category="";
public String report_location_name="";
public String report_lat;
public String report_long;
public String report_media="";
}
这是我在数据库中插入一行的数据库处理程序类。
public class DatabaseHandler extends SQLiteOpenHelper{
private static final String LOG = DatabaseHandler.class.getName();
// Database version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "reportsManager";
// Table names
private static final String TABLE_REPORT= "report";
// Helper Table Columns names
private static final String REPORT_TITLE="title";
private static final String REPORT_DESCRIPTION="description";
private static final String REPORT_CATEGORY="category";
private static final String REPORT_LOCATION_NAME="location";
private static final String REPORT_LAT="latitude";
private static final String REPORT_LONG="logitude";
private static final String REPORT_MEDIA="media";
// Helper table create statement
private static final String CREATE_TABLE_REPORT = "CREATE TABLE "
+ TABLE_REPORT + " ( " + REPORT_TITLE + " TEXT, " +
REPORT_DESCRIPTION+ " TEXT, " + REPORT_CATEGORY + " TEXT," + REPORT_LOCATION_NAME +
" TEXT, "+ REPORT_LAT+" TEXT, "+ REPORT_LONG+" TEXT, "+REPORT_MEDIA+" TEXT"+")";
// Constructor
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
//Creating required tables
db.execSQL(CREATE_TABLE_REPORT);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + CREATE_TABLE_REPORT);
// create new tables
onCreate(db);
}
void addReport(Report reports) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(REPORT_TITLE, reports.report_title);
values.put(REPORT_DESCRIPTION, reports.report_descrption);
values.put(REPORT_CATEGORY, reports.report_category);
values.put(REPORT_LOCATION_NAME, reports.report_location_name);
values.put(REPORT_LAT, reports.report_lat);
values.put(REPORT_LONG, reports.report_long);
values.put(REPORT_MEDIA, reports.report_media);
// Inserting Row
db.insert(TABLE_REPORT, null, values);
db.close(); // Closing database connection
}
}
现在,如果我插入数据库,LogCat会发生以下错误。有人可以帮帮我吗?
android.database.sqlite.SQLiteException: table report has no column named logitude: , while compiling: INSERT INTO report(category,title,logitude,latitude,media,location,description) VALUES (?,?,?,?,?,?,?)