Here is a quick snippet of code which will help us in getting the current status of an Android device’s data connection.  We make use of the _ConnectivityManager_ class to get current active network information. We try to catch a NullPointerException which is thrown by the isConnected method when there is no active data connection.

/**
 * Returns availability of a data connection
 * @param mContext
 *            Context of app
 * @return True is data connection is available , false otherwise
 */
public static boolean isDataConnectionOn(Context mContext) {
    ConnectivityManager connectionManager = (ConnectivityManager) mContext
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    try {
        if (connectionManager.getActiveNetworkInfo().isConnected()) {
            Log.d("ConStatus", "Data Connection On");
            return true;
        } else {
            Log.d("ConStatus", "Data Connection off");
            return false;
        }
    } catch (NullPointerException e) {
        // No Active Connection
        Log.d("ConStatus", "No Active Connection");
        return false;
    }
}

Please let me know if I am doing something incorrectly here.