Until it's almost dead, 3 years usually. My phone reached end of support. I don't want to get a new one, but Nokia's bootloader unlock site has been down for a couple of months now and I can't unlock it.
SD card and headphone jack are important to me, pixel is not an option.
What's the longest period you had a device?