我再次遇到Android数据库的问题。这次它再次向我显示错误:插入数据库时出错。数据库没有名为coverurl的列,而它就在那里。有什么问题?
public static final String TABLE_NAME = "gifs";
public static final String NAME = "name";
public static final String RATING = "rating";
public static final String DATE = "date";
public static final String URL = "url";
public static final String COVERURL = "coverurl";
private static final String DATABASE_NAME = "gifs.db";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE = "create table " + TABLE_NAME + "(" + NAME + " text" + "," + RATING
+ " int" + "," + URL + " text" + "," + DATE + " text" + "," + COVERURL + " text" + ");";
public SqliteHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
//Log.i("DATA BASE", getDatabaseName());
}
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
database.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(database);
}
}
这是一个LOGCAT:
04-12 16:28:27.770: E/Database(20963): Error inserting coverurl=http://i1.kwejk.pl/site_media/obrazki/2013/08/d18316c4c5a92ea4a3bbf5cd8bc34d5a_original.gif?1376656456 rating=444 date=1397316244427 url=http://i1.kwejk.pl/site_media/obrazki/2013/08/d18316c4c5a92ea4a3bbf5cd8bc34d5a_cropped.gif?1376656456 name=fff
04-12 16:28:27.770: E/Database(20963): android.database.sqlite.SQLiteException: table gifs has no column named coverurl: , while compiling: INSERT INTO gifs(coverurl, rating, date, url, name) VALUES(?, ?, ?, ?, ?);
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1569)
04-12 16:28:27.770: E/Database(20963): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
04-12 16:28:27.770: E/Database(20963): at pl.app.storage.DataBaseManager.insertGifToDataBase(DataBaseManager.java:45)
04-12 16:28:27.770: E/Database(20963): at pl.engine.main.MainActivity.onActivityResult(MainActivity.java:193)
04-12 16:28:27.770: E/Database(20963): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
04-12 16:28:27.770: E/Database(20963): at android.app.ActivityThread.deliverResults(ActivityThread.java:2549)
04-12 16:28:27.770: E/Database(20963): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595)
04-12 16:28:27.770: E/Database(20963): at android.app.ActivityThread.access$2000(ActivityThread.java:121)
04-12 16:28:27.770: E/Database(20963): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
04-12 16:28:27.770: E/Database(20963): at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 16:28:27.770: E/Database(20963): at android.os.Looper.loop(Looper.java:123)
04-12 16:28:27.770: E/Database(20963): at android.app.ActivityThread.main(ActivityThread.java:3701)
04-12 16:28:27.770: E/Database(20963): at java.lang.reflect.Method.invokeNative(Native Method)
04-12 16:28:27.770: E/Database(20963): at java.lang.reflect.Method.invoke(Method.java:507)
04-12 16:28:27.770: E/Database(20963): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
04-12 16:28:27.770: E/Database(20963): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
04-12 16:28:27.770: E/Database(20963): at dalvik.system.NativeStart.main(Native Method)