How is data transferred between devices? If you send a text from your phone to your friend, do electrons move from your phone to your friend's phone? How is text transferred (physics wise)? I am a programmer and I want to know how it is working.
 A: It is less of a "sending electrons," and more of jiggling them.  Think of a wave, done by the crowd at a sporting event.  One person raises their hands high, and then sits back down.  The next person raises their hands, and sits back down.  So on and so forth.  When we get to the end, its not that someone's hands moved from one side of the bleachers to the other.  Its a pattern that moved.  Each person doing the wave lead the next person to do the wave.
Its the same game with RF communication, like cell phones use.  They move electrons around within the antenna a tiny amount (fractions of a picometer!), which creates an electromagnetic potential -- electrical and magnetic charges moving just like the wave moves down the bleachers.  On the receiving end, the cell phone tower watches how the electrons in its antenna move.  It uses that to figure out what messages each of the cellphones is sending.
Of course, these signals are more complicated than the wave at a sporting event.  At the sporting event, it is just one wave (sometimes two waves) moving along a row of people.  In RF communication, we send a stream of very particular movements which convey the information.  The easiest to understand would be a human-scale signal like morse code, with its dots and dashes that everyone has heard at some point.  More complex ones like QAM are carefully chosen to have desirable behaviors and use the medium efficiently.
A: Information is "a difference that makes a difference". This means that you have physical systems that can be in different states, and that different states have different effects on other systems. Usually we try to make such differences resistant to noise from the environment, easy to read out or change, etc. A "logical bit" (the abstraction software deals with) is implemented as a "physical bit" which is usually a small circuit that retains its state over time, but could in principle be magnetization on a hard drive or core memory crossing, charge on a capacitor, part of an acoustic wave train in a delay line, or a lot of other things. Transmission can also be done in multiple forms.
When you copy a bit from one device to another it usually undergoes some operations in the abstraction that is software - it might be sent to an I/O port, encrypted, and undergo all the transformations needed for the OSI stack. But what you ask about is the physical layer. Typically what happens is that a memory state is read out (depending on its state wires on a bus become +5 or 0V, representing it as a voltage), that then is used to set other memory states elsewhere, and if transmitted by radio it becomes an electromagnetic signal (not up to speed on the encodings used in current cell networks, but the bit is likely encoded in signal phase, I think). The signal is received by a receiver, converted into an electric signal which is turned from analog to digital and interpreted as a bit, and then copied into some memory circuit. Repeat for all bits in the message.
Note that "the" bit becomes many things, but if everything works as it should, if the initial bit is X the final bit after all transformations will also be X with a high probability. What has been exchanged is a pattern, not any particular electrons or units of energy.
A: I have drawn a diagram to illustrate the mechanisms of how telecommunications work. This is a highly simplified cartoon of what happens. What I’ll be describing is in part often described in Telecom as Layer 0. All other layers have more to do with software than physics.   That being said lets go through he parts.


*

*Blue is for Microwaves sent from Cell Phone or Tower

*Purple is for Electronics

*Red is for Infra-Red laser light travelling through glass fiber optics.


*

*Cell phone sends microwaves (often 4G if you use say FB Messenger/WhatsApp ~ 2GHz in frequency)

*Cell phone tower receives it and interprets it electrically before sending the information in the form of modified laser light along glass fibers to an ISP (Internet Service Provider)

*The ISP (which has a building in each city) sends it to some other building they have via Laser light again. This next building could be very far (100km to 2000km and larger), basically where ever your friend is. Laser light is about 193 THz or 1550 nm.

*the Building send it to a cell tower via laser light again

*Cell tower talks to the cell phone via microwaves.

I have included another diagram on how the laser light is modified. Again, this is a highly simplified diagram.

*

*A computer that has data (binary 0 ,1) talks to a driver to send an electrical signal

*A laser light always turned on a specific frequency gives you very nice steady source of ~1550 nm Infrared light

*From 1) the electrical signal manipulate a driver that influences a modulator

*modulator is what controls the laser light and imparts data into it by modifying it’s phase or it’s power.

*Laser light finally travels downs glass fibers a few microns in diameter for a very long distance.


As you can tell from the above diagrams, it’s a very complicated process but I hope to have given you a rough description of how it works.
I have notably NOT included

*

*Amplifiers

*how the ISP knows which cell phone tower data is sent to

*How the cell phone tower knows which one is communicating with it

*The mechanism microwaves are sent by your cellphone

*how communication between continents work (Read Submarine Telecom)

*All the other buildings/internet boxes between cell tower and ISP

*Routing and switching

A: "I am a programmer and I want to know how it is working."
Oh my, in your quest to understanding, you started out with arguably the most complex system we humans ever came up! Thankfully, there is a good didactic tool to learn about this, the OSI Layer model, sometimes a bit abbreviated or reworded in the Internet Protocol Suite. These models can give you a structured direction in which to look, and all joking aside, are very useful (I would say indeed critical) for any programmer to know these days.
To answer your concrete questions: yes, at the very lowest level, all information that flows between the devices is directly represented or effected through electromagnetism, i.e., involving photons and electrons in some way or the other. This is the only one of the 4 fundamental forces of the universe which is open for us humans to directly use for practical manipulation.
If you touch your phone and send an emoticon to your friend, no electron is traveling the whole distance. Probably, by the time your friend replies with his own message, no electron in your phone has actually moved any visible amount at all.
Imagine you have a very long garden hose connected to the tap, completely filled with water, closed at the spout, and under pressure. In the very instant when you open the spout, water shoots out immediately, although it clearly had no time to travel from the tap to the spout. The water that shoots out at first already was at the spout, and is simply pushed from behind. It happens fast because water is relatively uncompressible.
Now imagine building a steampunk device where that water drives a water wheel, connected through an axle to some other mechanism which paddles water in a long and slim trough. You can easily imagine that when you target the water wheel with your garden hose it turns the axle, which in turn turns the paddles on the other side, which makes the water in that trough move along, although not a single drop of water from your hose ever makes it way into the through. In fact, this is exactly what they did when they had steam engines driving those big paddle ships on rivers like the Mississippi (with water vapor/steam instead of your garden hose of course).
The same is true for our information technology. Locally, you could in principle think about electrons moving around (although don't tell this to an actual physicist - they are far beyond considering electrons as little billiard balls, it's all about quantum fields these days...), but even if you only look at a very simple wire with direct current (i.e., something like a old-fashioned torch - a battery connected to a lamp with some trivial wiring), you have the effect from the garden hose in that the lamp starts to emit light long before the individual electrons coming "out of the battery" are arriving there. And in our current electronics, as soon as you have something like WIFI or fiber optical cables, there are no electrons involved anymore at all (in the case of WIFI or other radio-based communications it is electromagnetic waves or, equivalently, photons; in the case of optical cables, again, photons).
Just to give you an impression, the speed of an individual electron would be the Drift Velocity, and that link contains a practical example which turns out to be in the order of 20 μm/s, which is ludicrously slow. While at the same time the "water hose speed" would be 1570 km/s.
A: All I really have to add to the other answers is to provide some context to complete the picture.
You probably know that when you send something (like a text, or a web request) over a network, it is packaged in some data structure, then passed through several layers of software (various network libraries and so on), that manipulate it in various ways, break it down, wrap stuff into their own data structures, and so on. This is so that network infrastructure computers are able to determine where to send these packages, as well as to provide other services (security, caching, etc.).
So, you are not really sending data directly to a different phone/computer, you are sending it to your immediate network, with some metadata attached that tells network infrastructure computers (or rather, the software running on them) what's the intended destination, so they can use their own internal knowledge of network topology to decide where to forward it - and this process repeats until your data ultimately arrives at the intended destination. This all works because it's governed by various standards and protocols.
At the other end, the software libraries sort of work backwards to undo all this packaging and recombine your data before giving it back to your own application to handle.
So, the "connection" between your phone/computer and a different phone/computer is virtual in the sense that there's no single uniform physical line of communication between the two, but there are all these intermediaries. This means that your data may travel over a bunch of different physical connections that make use of different physical phenomena to transfer data.
As you know, all this data is (as everything else), ultimately represented as bytes, composed of bits. So the physical transport mechanism ultimately has to rely on a digital-to-analog converter of some sort to encode the bits in some way into a signal, and then transfer that signal sufficiently undiminished and unaltered so that the the bits can be reconstructed from it on the other end. So your data (or chunks of it) can be decoded (read as bytes), repackaged and re-encoded (sent out as a physical signal) a bunch of times before it reaches its destination.
The encoding might look something like this

with two different amplitudes representing 0 and 1. Two people could send a Morse code—like signal using this method over an ordinary rope - by jiggling it more or less vigorously at the sender's end.
Or perhaps it's something like this

with 0 and 1 encoded as different frequencies. Or it might use some other scheme. In some sense, this is a physical layer equivalent of a data structure, and the encoding scheme must be agreed upon by the two ends so that the signal can be correctly interpreted as bits.
There's a high frequency carrier signal, that is then manipulated to encode a lower frequency signal that is the actual data, using a device called a modulator.
At the other end, the signal has to be extracted by a demodulator and digitized - some piece of equipment will sample it at a sufficiently high frequency to be able to distinguish the parts that represent zeros from parts that represent ones, and it'll convert it back into bytes.
So, it's not electrons that travel to the other end. If it's a wire, we rely on their ability to affect nearby electrons and propagate the influence to the other end. We get wave-like behavior because we use alternating current. In metals, the outermost electrons are not really bound to individual atoms; they sort of float around, so there's a "soup" of electrons which act as a medium for the signal.
If it's an antenna, we rely on the fact that jiggling electrons produces electromagnetic radiation (which is a wave) that then carries the signal in all directions outside of the antenna (or maybe in a focused directed beam), and ultimately causes the electrons to jiggle in some other piece of metal we call the receiver.
If it's laser light sent through optic fibers, it's also electromagnetic radiation, but a different mechanism; we rely on certain quantum-mechanical properties of photons and atoms, and on the fact that when given enough energy, electrons in atoms get "excited" - jump to a higher energy level, and then spontaneously release that energy as light and jump back.
