Change to getSharedPreferences to pass prefs between activities

This commit is contained in:
misaochan 2018-01-02 21:15:04 +10:00 committed by maskara
parent 13a73fdcac
commit fba7628f3c
2 changed files with 11 additions and 2 deletions

View file

@ -33,12 +33,21 @@ class DirectUpload {
}
void storeSharedPrefs() {
SharedPreferences sharedPref = fragment.getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences sharedPref = fragment.getActivity().getSharedPreferences("Direct Upload",Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("Title", title);
editor.putString("Desc", desc);
editor.apply();
/**
//TODO remove this
sharedPref = fragment.getActivity().getSharedPreferences(Context.MODE_PRIVATE);
String imageTitle = sharedPref.getString("Title", "");
String imageDesc = sharedPref.getString("Desc", "");
Timber.d("In DirectUpload, image title: " + imageTitle + " and image desc: " + imageDesc);
*/
}
void initiateGalleryUpload() {

View file

@ -240,7 +240,7 @@ public class ShareActivity
if (intent.hasExtra("isDirectUpload")) {
Timber.d("This was initiated by a direct upload from Nearby");
//TODO: Shift this into title/desc screen after upload initiated
SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE);
SharedPreferences sharedPref = this.getSharedPreferences("Direct Upload", Context.MODE_PRIVATE);
String imageTitle = sharedPref.getString("Title", "");
String imageDesc = sharedPref.getString("Desc", "");