Contextの取得方法を修正

This commit is contained in:
ろむねこ 2023-12-11 11:53:56 +09:00
parent d4e429fdca
commit 1fa625e948
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -16,13 +16,15 @@ import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.source.pref.repository.Common; import one.nem.lacerta.source.pref.repository.Common;
@AndroidEntryPoint
public class CommonImpl implements Common { public class CommonImpl implements Common {
@ApplicationContext
@Inject
Context applicationContext; Context applicationContext;
@Inject
public CommonImpl(@ApplicationContext Context applicationContext) {
this.applicationContext = applicationContext;
}
public String getStringValue(String key) { public String getStringValue(String key) {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
return pref.getString(key, ""); return pref.getString(key, "");