I have list view showing data from the database with the help of adapter. when I save data from my activity before calling async task data is saved from in the database. the following code is used to save data
thread.setUserId(userId);
thread.setType(MessageThread.OUT_MESSAGE);
thread.setRandomcode(StringUtility.generateRandomDigits(6));
thread.setOwned(true);
thread.setRequestor(userId);
thread.setThreadTopic(composeMsgEditText.getText().toString());
thread.setSolicitationId("54e5cb1a1c19016a0ddcc27e");
thread.setHashcode(HashUtility.encryptString(thread.getRandomcode() + thread.getUserId()));
thread.setStrippedHashCode(StringUtility.reduceToBytes(thread.getHashcode(), 16));
try {
thread.setThreadTopicEnc(EncryptionUtility.encrypt(thread.getThreadTopic(), thread.getStrippedHashCode()));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeySpecException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
thread.setRandomcode(StringUtility.generateRandomDigits(6));
threadDBAction.save(thread);
after this code I call async task to send these information to server.and finish the activity. But the adapter is not showing this data.
Then after I save the same data/ or update if present using the following code
String threadId = respBody.get("thread").toString();
thread.setThreadId(threadId);
thread.setCreatedAt(respBody.get("created_at").toString());
thread.setIcon((Integer) respBody.get("icon_idx"));
thread.setIconColor((Integer) respBody.get("icon_color_idx"));
if (isMessagePresent) {
action.updateCreateThread(thread);
} else {
if (isAskForFeddback) {
action.save(thread);
}
}
then the lisview gets updated.
I use the following code to fetch data from db
static String[] projection = {
"_id",
"messageId",
"messageTopic",
"messageTopicEnc",
"messageType",
"requestor",
"usercode",
"user",
"randomcode",
"hashcode",
"strippedHashcode",
"solicitationId",
"blocked",
"blockedAt",
"closed",
"closedAt",
"createdAt",
"receivedAt",
"toAddresses",
"liked",
"disliked",
"likecount",
"dislikecount",
"poked",
"rkey",
"code",
"url",
"ref",
"icon_idx",
"icon_color_idx",
"action",
"visibility",
"scope",
"polltype",
"option1",
"option2",
"option3",
"option4",
"option5",
"answer",
"reply_at",
"response_count",
"option1_count",
"option2_count",
"option3_count",
"option4_count",
"option5_count",
"options_count",
"answered",
"correct_answer",
"answerEnc",
"askfeedback_email_counter"
};
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String select = " user LIKE ? AND ( usercode ="+0 +" OR usercode ="+1+" )";
return new CursorLoader(getActivity(), Uri.parse("content://"+DBContentProvider.MESSAGE_THREAD_URI),
projection, select, new String[] {((SwipeTabActivity) getActivity()).userId},
"createdAt DESC");
}
any solution to this problem?
Aucun commentaire:
Enregistrer un commentaire