저는 Android를 배우려고 노력하는 iOS 개발자이며 모범 사례를 따르고 있습니다.모든 활동에서 볼 수 있도록 맞춤 개체를 저장할 수있는 최적의 장소
1 -> m 액티비티가 액세스 할 수 있어야하는 사용자 지정 개체가 있으며 응용 프로그램을 닫을 때 저장해야합니다. 현재 SharedPreferences, 아래 코드를 사용하여 저장하고 있지만 최상의 경로인지 확실하지 않습니다. 싱글 톤을 사용해야합니까? 더 좋은 방법이 있습니까?
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
Editor prefsEditor = mPrefs.edit();
Gson gson = new Gson();
String json = gson.toJson(userProfile);
prefsEditor.putString("UserProfile", json);
prefsEditor.commit();
gson = new Gson();
json = mPrefs.getString("UserProfile", "");
UserProfileObject outObject = gson.fromJson(json, UserProfileObject.class);
나는 안드로이드 개발 학습을 통해 내 방식을 찾고있다. 나는 파일을 쓰는 방법을 알아낼 수있다. 고맙습니다 – user1079052