SOLVED. I just can’t accept the answer until 2 days has passed. Turned out that sqliteman was reading an old database after all.
I’m trying to read from the database in Android but I don’t get any results. The weird thing is that when I run the exact same query on the same database in sqliteman(a sqlite manager) it works perfectly.
My query in my DB-handler class:
//exact same as in code
String fetchVaccinesForCountryQuery =
"SELECT v._id, v.vname, v.text " +
"FROM vaccine v, vacc_disease vc " +
"WHERE v._id = vc.vaccineId and vc.diseaseId IN (SELECT cd.diseaseId " +
"FROM country_disease cd " +
"WHERE cd.countryId = %d)";
//and a version that's a bit easier to read...
String fetchVaccinesForCountryQuery =
"SELECT v._id, v.vname, v.text
FROM vaccine v, vacc_disease vc
WHERE v._id = vc.vaccineId and vc.diseaseId
IN (SELECT cd.diseaseId
FROM country_disease cd
WHERE cd.countryId = %d)";
public Cursor fetchVaccinesForCountry(long countryId) {
String query = String.format(fetchVaccinesForCountryQuery, countryId);
Log.d("TripDb", "fetchStr: " + query);
return mDb.rawQuery(query, null);
}
I’ve written an info provider that calls that function:
Cursor c = mDb.fetchVaccinesForCountry(countryId);
Log.d("InfoProvider", "numVaccines = " + c.getCount());
The logcat string showing the query looks like this:
fetchStr: SELECT v._id, v.vname, v.text FROM vaccine v, vacc_disease vc WHERE v._id = vc.vaccineId and vc.diseaseId IN (SELECT cd.diseaseId FROM country_disease cd WHERE cd.countryId = 3)
While the Logcat showing number is
numVaccines = 0
But when I pull the database with adb and run the same query in SqliteMan I get 7 results. I’m kind of stumped as to why Android doesn’t give me 7 results.
So…this is slightly embarrasing. It turned out that when I thought SqliteMan reloaded the database it was using an old file. Once I discovered that I could starting hunting the real error and now everything’s working…