Vote count:
0
I'm trying to accomplish the transfer of a string value from a Fragment to an Activity below. The result of the transfer says that the value is empty when transferred to the activity. Please let me know if you need more information.
Fragment:
//put selected chapter title in memory
String selectedChapter = chapters[position];
SharedPreferences pref = getActivity().getPreferences(0);
SharedPreferences.Editor edt = pref.edit();
edt.putString("selectedChapter", selectedChapter);
edt.commit();
//launch activity
Intent intent = new Intent(getActivity(), ChapterDetailActivity.class);
startActivity(intent);
Activity:
//retrieve selected chapter filename from previous view
SharedPreferences pref = ChapterDetailActivity.this.getPreferences(0);
String filename = pref.getString("selectedChapter", "empty");
Log.e("File: ", filename);
asked 42 secs ago
Aucun commentaire:
Enregistrer un commentaire