Monday, May 16, 2011

Onto the database test!

Now that we've cleared up the database not closed exception once and for all (we hope), it's time to implement database access in our test case for database initialization. Let's review the current stub method again:

public static void initializeQuestionsSQL(JlptQuizStartActivity a,
AppState appState) {

a.testAnswer = "青い";
}

Let's have it access the database:

public static void initializeQuestionsSQL(JlptQuizStartActivity a,
AppState appState) {

ArrayList rows = null;

DataBaseHelper myDbHelper = Utils.createDB(a);

rows = myDbHelper.selectByLevelAndNumber(5, 3);

myDbHelper.close(); // <========= don't forget this!

Question question = rows.get(0);

a.testAnswer = question.kanji;
}

The tests worked. Now, use the application object for the parameters.


public static void initializeQuestionsSQL(JlptQuizStartActivity a,
AppState appState) {

ArrayList rows = null;

DataBaseHelper myDbHelper = Utils.createDB(a);

rows = myDbHelper.selectByLevelAndNumber(appState.jlptLevel, appState.currentQuestion);

myDbHelper.close();

Question question = rows.get(0);

a.testAnswer = question.kanji;
}

I've been having trouble getting the test to launch recently, and have had to disconnect and reconnect my usb connection the device. Now, I'm getting a "too many files open message". Looks like it's time for a reboot, at least of the phone.

Well, it did launch, albeit slowly enough. The next step will be to find read through all the words at the current level, and load up the words table based on that. We'll save that for tomorrow.

No comments:

Post a Comment