I have a problem with IntentService, I have an activity with three spinner they get the State, City and Neighborhood from a Webservice where the IntentService performs this task and within step onReceive to the Spinner. When the person selects the state automatically the other spinners are filled with the cities and neighborhoods of that state. This works correctly but I need this last user query to be saved in an android sqlite and I put the code in the same IntentService the question is that it can insert into the sqlite database the states that are in the first spinner only when it will give statService ) again to enter the cities the app gives error and date. Just a detail if I take the command below it works correctly. I do not know why this conflict.
ClasseCriarBanco banco = new ClasseCriarBanco(this, "banc.db", null, 1);
ContentValues valor = new ContentValues();
SQLiteDatabase db = banco.getWritableDatabase();
// banco.close();
//ClasseCriarBanco banco2 = new ClasseCriarBanco(this, "banc.db", null, 1);
SQLiteDatabase dbleitura = banco.getReadableDatabase();
String [] colunas = {banco.ID,banco.ESTADO};
//
Cursor cur = db.query(banco.TABELA,colunas,null,null,null,null,null);
Cursor cur2 = dbleitura.rawQuery("SELECT _id, estado FROM tabela order by estado desc LIMIT 1",null);
if(cur.getCount() > 0){
cur.moveToPosition(i-1);
registroatual = cur.getString(cur.getColumnIndexOrThrow(banco.ESTADO));
cur2.moveToFirst();
ultimoregistro = cur2.getString(cur.getColumnIndexOrThrow(banco.ESTADO));
}else{
registroatual = "primeiroregistro";
ultimoregistro = "primeiroregistro";
}
if (pegaurl.equals("http://listarapido.esy.es/estados") && registroatual.equals(ultimoregistro)){
valor.put(ClasseCriarBanco.ESTADO, finaljs);
db.insert(TABELA,null,valor);
}