When I run the below code I get:
java.lang.IllegalStateException: database not open
I don't understand this because I clearly see db.open() above my code. Any help with this would be greatly appreciated.
the DbAdapater code
it fails once db.infoSent is called and it reaches the "if(mDb.update" line
does it have something to do with it being in the else statement? or with the cursors that are sitting in the map?
I got the program to run right by rearranging some stuff, but I still have to open the database right before my call to infoSent... why would this be?
java.lang.IllegalStateException: database not open
I don't understand this because I clearly see db.open() above my code. Any help with this would be greatly appreciated.
Code:
db = new DbAdapter(SyncService.this);
showNotification("Sync Running");
db.open();
Map<String, Cursor> results = db.updateList(communityGuid);
Cursor newInfo = results.get("newInfo");
String infoEnv = "";
if(newInfo.moveToFirst())
{
ArrayList<String> infos = new ArrayList<String>();
infoEnv = AddInfoPrefix();
while(!newInfo.isAfterLast())
{
infos.add(newInfo.getString(6));
infoEnv+=AddInfo(newInfo.getString(0), newInfo.getString(1), newInfo.getString(2), newInfo.getString(3), newInfo.getString(4), newInfo.getString(5), newInfo.getString(6));
newInfo.moveToNext();
}
infoEnv+=AddInfoSuffix();
soapAction = buildSoapAction("AddInfo");
if(!httpAndParse("addInfo", infoEnv, soapAction, communityGuid, ip))
{
successful = false;
}
else
{
db.infoSent(infos);
}
}
newInfo.close();
db.close();
Code:
public boolean infoSent(ArrayList<String> ids)
{
boolean fail=false;
ContentValues Con = new ContentValues();
Con.put(KEY_NEW, 0);
for(String id : ids)
{
if(mDb.update(DATABASE_TABLE2, Con, KEY_ID + "=?", new String[]{id})<=0)
{
fail=true;
}
}
return !fail;
}
does it have something to do with it being in the else statement? or with the cursors that are sitting in the map?
I got the program to run right by rearranging some stuff, but I still have to open the database right before my call to infoSent... why would this be?