I think you done the right thing. It's just one of those things. It's hard to fold AK preflop it's a strong hand just happened to run into a stronger one. In future just keep an eye on weather the player your against is tight or loose. The tighter they are the more likely they have a monster.
Maybe you should call at some point and see the flop. Even if the flop does not fit very well to your hand, a coordinated board can be used to bluff. Even pocket aces can be dropped if there are three suited cards on the flop. Exposing All-In with preflop, you immediately deprive yourself of fold equity. And are forced to rely only on luck.
Maybe you should call at some point and see the flop. Even if the flop does not fit very well to your hand, a coordinated board can be used to bluff. Setting all-in with pre-flop is not the best tactic with any hand.