I have Samsung Galaxy S3 in the charger 24/7, so it's not good for battery. How can I set charging so that the phone spends battery to say 30% before charging it to full?
If your device is not rooted, it's not possible
If it's rooted, it's possible but you have to get your hands dirty, since ways below target to cut off battery charging at upper limit and not while discharging to a lower limit , as you want
[APP][ROOT][4.4+]Battery Charge Limit v1.0.1 available free at XDA works for your device as can be seen from linked user post. You can download the app from here. Fortunately, this is open source so you can tinker with it
Have a look at this for trying other ways of achieving your goal Automatically limit (stop) battery charging at a given percentage . Here again, the actions of discontinue charging can be configured to lower limit