できる限り検索しましたが、助けが見つかりません。明らかに2列以上のデータベースを作成することになりました。誰かが私を助けてくれる情報源を教えてくれる場所はありますか? また、パフォーマンスのために別のデータベースを使用する必要があります。
私が得るエラーメッセージは次のとおりです。
CursorWindow フィールド スロット 0、2 の不正な要求。numRows = 3. numColumns = 2
@Override
public void onCreate(SQLiteDatabase db) {
String sql = String
.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER NOT NULL, %s TEXT NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s REAL NOT NULL, %s REAL NOT NULL, %s REAL NOT NULL, %s REAL NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL, %s INTEGER NOT NULL);",
EXERCISES_TABLE, COL_ID, EXERCISE_ID, NAME,
TYPE_OF_TRAINING, WEIGHT_BEST, SETS_BEST, REPS_BEST,
SETS, REPS, WEIGHT_GOAL, SETS_GOAL, REPS_GOAL,
DISTANCE, TIME, BEST_TIME, BEST_DISTANCE, BEST_DATE,
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY);
db.execSQL(sql);
}
また、データを取得しようとしている方法:
public List<Exercise> getExerciseList() {
List<Exercise> retEx = new ArrayList<Exercise>();
SQLiteDatabase db = getReadableDatabase();
String sql = String.format("SELECT %s, %s FROM %s ORDER BY %s",
EXERCISE_ID, SATURDAY, EXERCISES_TABLE, COL_ID);
Cursor cursor = db.rawQuery(sql, null);
while (cursor.moveToNext()) {
int id = cursor.getInt(0);
String name = cursor.getString(1);
int typeOfTraining = cursor.getInt(2);
int weightBest = cursor.getInt(3);
int setsBest = cursor.getInt(4);
int repsBest = cursor.getInt(5);
int sets = cursor.getInt(6);
int reps = cursor.getInt(7);
int weightGoal = cursor.getInt(8);
int setsGoal = cursor.getInt(9);
int repsGoal = cursor.getInt(10);
float distance = cursor.getFloat(11);
float time = cursor.getFloat(12);
float bestTime = cursor.getFloat(13);
float bestDistance = cursor.getFloat(14);
int bestDate = cursor.getInt(15);
int sunday = cursor.getInt(16);
int monday = cursor.getInt(17);
int tuesday = cursor.getInt(18);
int wednesday = cursor.getInt(19);
int thursday = cursor.getInt(20);
int friday = cursor.getInt(21);
int saturday = cursor.getInt(22);
retEx.add(new Exercise(name, weightBest, setsBest, repsBest, sets,
reps, weightGoal, setsGoal, repsGoal, distance, time,
bestTime, bestDistance, bestDate, typeOfTraining, id,
sunday, monday, tuesday, wednesday, thursday, friday,
saturday));
}
db.close();
return retEx;
}