I'm pretty new to Android programming (and Java programming) and there is something I don't get.
I've created a class extending SQLiteOpenHelper and in the onCreate method I create the table like that:
@Override
public void onCreate(SQLiteDatabase db) {
// Table to store every single movie and its information.
final String SQL_CREATE_MOVIE_TABLE= "CREATE TABLE " + MovieEntry.TABLE_NAME + " (" +
MovieEntry._ID + " INTEGER PRIMARY KEY," +
MovieEntry.COLUMN_ORIGINAL_TITLE + " TEXT NOT NULL, " +
MovieEntry.COLUMN_POSTER_PATH + " TEXT, " +
MovieEntry.COLUMN_SYNOPSIS + " TEXT, " +
// Gonna store the date the same format it's provided: ISO8601
MovieEntry.COLUMN_RELEASE_DATE + " TEXT, " +
MovieEntry.COLUMN_POPULARITY + " REAL NOT NULL, " +
MovieEntry.COLUMN_VOTE_AVERAGE + " REAL NOT NULL, " +
MovieEntry.COLUMN_VOTE_COUNT + " INTEGER NOT NULL, " +
MovieEntry.COLUMN_IS_FAVORITE + " BOOLEAN NOT NULL DEFAULT 0 " +
" );";
db.execSQL(SQL_CREATE_MOVIE_TABLE);
}
I'm running it using the AndroidTestCase class and it works as expected (table gets created and I'm able to see the metadata created in the SQLite db).
My question is the following: The table creation gets called every single time I run the test, but never throw any exception. I don't see where it's handled in the code going deeper in the execSQL function and the method does not return anything.
Am I missing something here or is that intended?
Aucun commentaire:
Enregistrer un commentaire