Resource injection for SharedPreferences

See #536