내 모델 SharedPreferences를 저장하고 별도의 파일에 저장/읽기 방법을 사용할 수 있습니까? app 활동에서 SharedPreferences를 사용하여 작업하고 싶습니다. 어떻게해야합니까?SharedPreferences in separate file
답변
Simple..Make 그것은 정적 클래스에서
을 응용 프로그램 A의 SharedPrefrence에 액세스 할 수없는 등의
pubic void retrieveText(String textKey){
//Get info from the preference file.
}
로
안드로이드 자체가 sharedpreferences를 활용할 수있는 좋은 방법을 제공 할 때이 일을하는 목적을 알지 못합니다. 이것은 당신이가는 길입니다.
희망이 있습니다.
편집 :
import android.content.SharedPreferences;
고마워,하지만 MySharedPreferences.java에서'SharedPreferences sharedPref;를 얻을 수 없다. \t SharedPreferences.Editor prefEditor;'. 이것은 활동적인 활동만을위한 것입니다. 아니면 활동에 대한 참고서를 전달해야합니까? –
활동에 대해서만 무엇을 의미합니까? .Java 클래스에서 sharedpreference 메서드를 호출 할 수 있어야합니다 ..... –
코드로 무엇을 하려는지 보여줍니다. –
각 앱마다 고유 한 공유 출입구가 있습니다. 그것을 당신이 적절한 파일에 넣음으로써 무슨 뜻인지 모르시겠습니까 ??
물론 앱 내에서 SharedPrefrences에 액세스하는 별도의 메소드를 사용할 수 있습니다. 당신은 필요할 때 정보를 검색됩니다 방법을 추가 .. 응용 프로그램 B.
내 단일 응용 프로그램에서 단일 클래스 - MySharedPreferences를 사용하여 하나의 개별 파일을 만들고 싶습니다. 거기서 나는 장소 모델 prefences와 그것으로 모든 논리적 인 작업을 원한다. 모든 활동은이 수업과 상호 작용해야합니다. –
그럼 정적 클래스로 만드십시오 ... –
예를 들어 두 개의 액티비티가 상호 작용할 수있는 곳이 어디 있겠습니까? –
- 1. NSComparator in Separate File
- 2. IValidatableObject in separate assembly
- 3. XtraGrid Master-Detail in separate grid
- 4. concordance file in python
- 5. div in css3 file
- 6. Wordpress File in dreamhost
- 7. File logger in C#
- 8. File Upload in Documentum in ajax
- 9. grails file uploads in wars
- 10. Performant File Copy in C#?
- 11. rss xml file in PYTHON
- 12. EasyMock and File in Java
- 13. asset_path in scss file rails
- 14. JQuery .append() Separate Elements
- 15. Separate Polymorphic Association 테이블
- 16. SHA1 form .exe file in C#
- 17. 자바 스크립트 Find in .TXT File
- 18. 간헐적 인 "File in Use"오류
- 19. Visual Studio "File in use ..."빌드가 실패했습니다.
- 20. 된 SharedPreferences -
- 21. GUI 양식 업데이트 Separate Class
- 22. 워크 플로 파운데이션 Separate Schema
- 23. cloudControl addons as separate service
- 24. SharedPreferences Validation
- 25. SharedPreferences 문제
- 26. 된 SharedPreferences
- 27. 직렬화를위한 SharedPreferences?
- 28. SharedPreferences & boolean
- 29. Android SharedPreferences
- 30. SharedPreferences 클래스
당신이 좀 더 구체적인 수 있을까? –
아래의 주석 참조 –