Your described circuit probably won't work, but you could probably do something with a relay. Basically when plugged into the wall, you'd need to disconnect the battery and connect the supply.
Your described circuit probably won't work, but you could probably do something with a relay. Basically when plugged into the wall, you'd need to disconnect the battery and connect the supply.