Добавление большего количества столбцов в базу данных, которая уже работала (добавлены плюс и минус). Я посмотрел на предыдущие ответы, но не могу, чтобы жизнь меня обнаружила ошибку в моем синтаксисе.SQLiteException нет такого столбца: plus (код 1)
private static final String TAG = "DBAdapter";
// DB Fields
public static final String KEY_ROWID = "_id";
public static final int COL_ROWID = 0;
/*
* CHANGE 1:
*/
// TODO: Setup your fields here:
public static final String KEY_NUMBER = "number";
public static final String KEY_LASTNAME = "lastname";
public static final String KEY_FIRSTNAME = "firstname";
public static final String KEY_POSITION = "position";
public static final String KEY_TIMEONICE = "timeonice";
public static final String KEY_PLUS = "plus";
public static final String KEY_MINUS = "minus";
// TODO: Setup your field numbers here (0 = KEY_ROWID, 1=...)
public static final int COL_NUMBER = 1;
public static final int COL_LASTNAME = 2;
public static final int COL_FIRSTNAME = 3;
public static final int COL_POSITION = 4;
public static final int COL_TIMEONICE = 5;
public static final int COL_PLUS = 6;
public static final int COL_MINUS = 7;
public static final String[] ALL_KEYS = new String[] {KEY_ROWID, KEY_NUMBER, KEY_LASTNAME, KEY_FIRSTNAME, KEY_POSITION, KEY_TIMEONICE,KEY_PLUS,KEY_MINUS};
// DB info: it's name, and the table we are using (just one).
public static final String DATABASE_NAME = "HOCKEY.db";
public static final String DATABASE_TABLE = "mainTable";
// Track DB version if a new version of your app changes the format.
public static final int DATABASE_VERSION = 7;
private static final String DATABASE_CREATE_SQL =
"create table " + DATABASE_TABLE
+ " (" + KEY_ROWID + " integer primary key autoincrement, "
/*
* CHANGE 2:
*/
// TODO: Place your fields here!
// + KEY_{...} + " {type} not null"
// - Key is the column name you created above.
// - {type} is one of: text, integer, real, blob
// (http://www.sqlite.org/datatype3.html)
// - "not null" means it is a required field (must be given a value).
// NOTE: All must be comma separated (end of line!) Last one must have NO comma!!
+ KEY_NUMBER + " integer not null,"
+ KEY_LASTNAME + " string not null,"
+ KEY_FIRSTNAME + " string not null,"
+ KEY_POSITION + " string not null,"
+ KEY_TIMEONICE + " string"
+ KEY_PLUS + " integer,"
+ KEY_MINUS + " integer"
// Rest of creation:
+ ");";
Вход кошки
01-01 21: 55: 16,971: Е/AndroidRuntime (3476): Процесс: com.example.timeonice, ПИД: 3476 01-01 21:55: 16.971: E/AndroidRuntime (3476): java.lang.RuntimeException: не удается запустить активность ComponentInfo {com.example.timeonice/com.example.timeonice.MainActivity}: android.database.sqlite.SQLiteException: нет такого столбца: плюс (код 1): при компиляции: SELECT DISTINCT _id, number, lastname, firstname, position, timeonice, plus, минус FROM mainTable 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.ActivityThread .performLaunch Активность (ActivityThread.java:2195) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2245) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.ActivityThread.access $ 800 (ActivityThread.java:135) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1196) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.os.Handler.dispatchMessage (Handler.java:102) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.os.Looper.loop (Looper.java:136) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.ActivityThread.main (ActivityThread.java : 5017) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at java.lang.reflect.Method.invokeNative (Native Met hod) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at java.lang.reflect.Method.invoke (Method.java:515) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:779) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at com.android.internal.os. ZygoteInit.main (ZygoteInit.java:595) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at dalvik.system.NativeStart.main (родной метод) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): вызвано: android.database.sqlite.SQLiteException: нет такого столбца: плюс (код 1): при компиляции: SELECT DISTINCT _id, number, lastname, firstname, position, timeonice, plus, минус FROM mainTable 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.database.sqlite.SQLiteConnection.nativePrepareStatement (собственный метод) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement (SQLiteConnection.java:889) 01-01 21: 55: 16.971: E/AndroidRuntime (3476) : at android.database.sqlite.SQLiteConnection.prepare (SQLiteConnection.java:500) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.database.sqlite.SQLiteSession.prepare (SQLiteSession.java: 588) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): в android.database.sqlite.SQLiteProgram. (SQLiteProgram.java:58) 01-01 21: 55: 16.971: E/AndroidRuntime (3476)): at android.database.sqlite.SQLiteQuery. (SQLiteQuery.java:37) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): на android.database.sqlite.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java: 44) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): в android.database.sqlite.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1314) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.database.sqlite.SQLiteDatabase.queryWithFactory (SQLiteDatabase.java:1161) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): на android.database.sqlite.SQLiteDatabase.query (SQLiteDatabase.java:1032) 01-01 21: 55: 16.971: E/AndroidRuntime (3476)): at com.example.timeonice.DBAdapter.getAllRows (DBAdapter.java:159) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at com.example.timeonice.DBAdapter.deleteAll (DBAdapter.java: 146) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at com.example.timeonice.MainActivity.onCreate (MainActivity.java:135) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.Activity.performCreate (Activity.java:5231) 01-01 21: 55: 16.971: E/AndroidRuntime (3476): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1087) 01-01 21: 55: 16,971: E/AndroidRuntime (3476): в android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2159)
Я очень смущен о том, как долго я смотрел на это ... Большое спасибо. – user3078867