Code example for SparseArray

Methods: keyAt, remove, size

0
    public void taskSucceeded(Object result, AsyncTask<?, ?, ?> task) {
        if (task.getClass() == SubmitQuestion.class) {
            // supprime de la liste et update le rating avec le vrai ID 
            QuizQuestion question;
            try { 
                final Integer key = questionToSend.keyAt(questionToSend.size());
                question = new QuizQuestion((String) result);
                if (ratingsToSend.get(key) != null) {
                    // si un rating est associe, on change l'id associe par le vrai 
                    ratingsToSend.get(key).setId(question.getId());
                } 
 
                Utils.printLogMsg('d', "OLS", "Want to Delete " + questionToSend.size());
 
                questionToSend.remove(key.intValue());
 
                Utils.printLogMsg('d', "OLS", "Deleted? " + questionToSend.size());
 
                // QuizQuestionCache.removeCachedQuiz(questionToSend.get(key.intValue())); 
 
                // QuizQuestionCache.removeCachedAfterBeSent(key); 
                Utils.printLogMsg('d', "OLS", "1 Question sent with new ID:" + question.getId());