android-lib/src/main/java/io/v/android/security/BlessingsManager.java
/**
     * Returns {@link Blessings} found in {@link SharedPreferences} under the given key.
     * <p>
     * Unlike {@link #getBlessings}, if no {@link Blessings} are found this method won't mint a new
     * set of {@link Blessings}; instead, {@code null} value is returned.
     *
     * @param context         Vanadium context
     * @param androidContext  android {@link Context} requesting blessings
     * @param key             a key under which the blessings are stored
     * @param setAsDefault    if true, the returned {@link Blessings}, if non-{@code null}, will be
     *                        set as default blessings for the app
     * @return                {@link Blessings} found in {@link SharedPreferences} under the given
     *                        key or {@code null} if no blessings are found
     * @throws VException     if the blessings are found in {@link SharedPreferences} but they
     *                        are invalid
     */
Returns  Blessings found in  SharedPreferences under the given key.

Unlike  #getBlessings, if no  Blessings are found this method won't mint a new
set of  Blessings; instead,  null value is returned.


Returns Blessings found in SharedPreferences under the given key . Unlike #getBlessings if no Blessings are found this method won ' t mint a new set of Blessings ; instead null value is returned .
public static Blessings readBlessings(VContext context, Context androidContext, String key,
                                          boolean setAsDefault) throws VException {
        String blessingsVom =
                PreferenceManager.getDefaultSharedPreferences(androidContext).getString(key, "");
        if (blessingsVom == null || blessingsVom.isEmpty()) {
            return null;
        }
        Blessings blessings = (Blessings) VomUtil.decodeFromString(blessingsVom, Blessings.class);
        if (blessings == null) {
            throw new VException("Couldn't decode blessings: got null blessings");
        }
        return setAsDefault ?
                VFutures.sync(wrapWithSetAsDefault(
                    context, androidContext, Futures.immediateFuture(blessings)))
                : blessings;
    }
public static Blessings readBlessings ( VContext context , Context androidContext , String key , boolean setAsDefault ) throws VException { String blessingsVom = PreferenceManager . getDefaultSharedPreferences ( androidContext ) . getString ( key , "" ) ; if ( blessingsVom == null || blessingsVom . isEmpty ( ) ) { return null ; } Blessings blessings = ( Blessings ) VomUtil . decodeFromString ( blessingsVom , Blessings . class ) ; if ( blessings == null ) { throw new VException ( "Couldn't decode blessings: got null blessings" ) ; } return setAsDefault ? VFutures . sync ( wrapWithSetAsDefault ( context , androidContext , Futures . immediateFuture ( blessings ) ) ) : blessings ; }
Returns {@link Blessings} found in {@link SharedPreferences} under the given key.
Returns { @link Blessings } found in { @link SharedPreferences } under the given key .
// TODO(spetrovic): validate the blessings and fail if they aren't valid