Yes, it is correct. It is the only correct way of saying this.
You cannot say 'I've been knowing her for four years' because 'know' is a stative verb. Stative verbs describe states rather than actions, and they cannot be used in continuous tenses. You can say 'I've been sharing a flat with her for four years', 'I've been working with her for four years' , 'I've been playing tennis with her for four years', and countless other statements describing repeated and/or continuing actions over this period. 'Share' 'work' and 'play' are examples of dynamic verbs describing actions, and they can be used in both simple and continuous tenses. Verbs describing states, such as 'I know Anna', can only be used in simple tenses.
I hope that helps.