Hello Taher, it depends on the type of visa you have. If you have a permanent resident permit, you will lose it if you are away for more than 6 months outside EU or more than 1 year within EU. You could get a special approval from the Ausländeramt to get an exceptional ok to stay outside for longer, but the approval is discretionary.
Hope it helps (****://***.trust7.***/forum/-/message_boards/message/757720)