List of usage examples for android.app Application getContentResolver
@Override
public ContentResolver getContentResolver()
From source file:com.commonsware.android.diceware.PassphraseFragment.java
private void loadWords(boolean forceReload, boolean regenPassphrase) { if (wordsObservable == null || forceReload) { final Application app = getActivity().getApplication(); wordsObservable = Observable .defer(() -> (Observable.just(PreferenceManager.getDefaultSharedPreferences(app)))) .subscribeOn(Schedulers.io()).map(sharedPreferences -> { PassphraseFragment.this.prefs = sharedPreferences; return (sharedPreferences.getString(PREF_URI, "")); }).map(s -> {//w ww . ja v a 2 s .c o m InputStream in; if (s.length() == 0) { in = app.getAssets().open(ASSET_FILENAME); } else { in = app.getContentResolver().openInputStream(Uri.parse(s)); } return (readWords(in)); }).cache().observeOn(AndroidSchedulers.mainThread()); } unsubWords(); if (regenPassphrase) { wordsSub = wordsObservable.subscribe(this::rollDemBones, error -> { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_LONG).show(); Log.e(getClass().getSimpleName(), "Exception processing request", error); }); } }