Q:

android which data connection

Should my Android phone automatically select wi-fi if available, if not then go to the next data service etc.    If I use
connectivity.setNetworkPreference(ConnectivityManager.TYPE_WIFI);

will that ensure the same result or confine it to using wi-fi only.

A:

Yes. By default android chooses WiFi network and if WiFi network is not available then it switches to mobile carrier network. To implement switch form WiFi to mobile network you can follow my answer over here: How to handle WiFi to Mobile network switch programatically?

