Just my opinion but (and I assume you want to plug in your guitar to your tablet not your phone):
Assuming you are on apple (most likely as android and other OS aren't as good for this stuff yet)
The best way is to purchase any of the devices that connect through the lightening port and not the headphone jack on the tablet. The downside being it's more expensive. So devices like the irig HD or HD 2, apogee jam, or line 6 sonic port.
Then shoot that into your audio interface on your computer into your DAW. If you really want to do it right I would suggest an impedance device like the ART cleanbox pro between your interface and your tablet.
Now assumeing you don't wanna do all that and want to go cheaper, any of the iOS devices will work. My experience with the ones that use the headphone jack instead of the lightening port is that they are noisy so if you go that route (using the headphone out on the device to your audio interface on your computer) keep the guitar cable as short as possible.
The first is ideal, the second will work ok. The first option is more expensive and TBH at that point I would personally look at computer software instead.