DanielPollithy / flashwifi

Wifiota - share WiFi p2p in exchange for iota on android
https://tobywoerthle.github.io/flashWiFiSite/
9 stars 1 forks source link

store last wallet balance in app #28

Closed DanielPollithy closed 6 years ago

DanielPollithy commented 6 years ago

If a device is not connected to the internet we can't show the current account balance. I guess we should store this (together with the last index) in the EncryptedSharedPreferences

What do you think, Toby?

tobywoerthle commented 6 years ago

@DanielPollithy Yeah, that makes sense. I can put an output message that the balance may not be up to date.

DanielPollithy commented 6 years ago

@tobywoerthle Thanks! The thing is that I want to check the balance of the user before starting a hotspot...

tobywoerthle commented 6 years ago

@DanielPollithy Use below function to retrieve shared pref for balance + balance update date time

ex.

String balance = getSharedPrefKey("balance");
String balanceUpdateDateTime = getSharedPrefKey("balanceDateUpdate");
private String getSharedPrefKey(String key) {
        SharedPreferences sharedPref = context.getSharedPreferences(prefFile, Context.MODE_PRIVATE);
        String defaultValue = "0";
        String storedBalance = sharedPref.getString(key,defaultValue);
        return storedBalance;
    }

I'll update this as soon as the app starts.

tobywoerthle commented 6 years ago

The balance will be updated when app starts and gets past seed login screen: 3e96e2fba6850cfc7c2fa65ef47c88fb80a0faef