10
Android SharedPreferences ใน Fragment
ฉันพยายามอ่าน SharedPreferences ใน Fragment รหัสของฉันคือสิ่งที่ฉันใช้เพื่อรับค่ากำหนดในกิจกรรมอื่น ๆ SharedPreferences preferences = getSharedPreferences("pref", 0); ฉันได้รับข้อผิดพลาด Cannot make a static reference to the non-static method getSharedPreferences(String, int) from the type ContextWrapper ผมได้พยายามที่จะติดตามการเชื่อมโยงเหล่านี้ แต่ไม่มีโชคเข้าถึง SharedPreferences ผ่านวิธีการแบบคงที่และ SharedPreferences แบบคงที่ ขอบคุณสำหรับวิธีแก้ปัญหาใด ๆ