If you're worried about losing every single contact when it's time to change smartphone, don't panic! There's a very simple solution that can make sure you recover all your contacts in a new handset. Simply save them online, either with Google if you use an Android phone, or Apple if it's an iPhone.
If you have an Android smartphone, go to the Contacts app then to Settings. Then select Import/Export and choose Export to SIM card. Then, you'll only have to perform the same operation on your new mobile to retrieve them all, taking care to select Import from the SIM card. Even simpler, some manufacturers, starting with Samsung or Huawei, offer applications dedicated to the recovery of data, including contacts, at each change of phone.
Note that if you change operator, you'll need to export or save your contacts to the device, this time, before reimporting them to your new SIM card.
But the best bet is to save all your contacts to the cloud, to your Google account. For that, with each new entry, be sure to select the option to save the contact to your Google account. Then, you'll automatically have access to them from any smartphone on which you are logged in.
To transfer data from one iPhone to another, the best option is to save everything online, to iCloud. To do this, select Contacts in the list of options in Settings/Apple ID/iCloud. This way, you can always retrieve them automatically on your new smartphone (or iPad or Mac).
This can apply to any data from your iPhone, not just the contacts. You can also manage (add, modify or delete) your contacts directly from the iCloud web platform. These changes will instantly update your contacts on your iPhone.