If you have not yet been charged with a crime, the police may still detain you for investigative purposes if they have objectively reasonable grounds to suspect that you are connected to a crime. While there are no precise time limits, this detention should be brief and only last as long as reasonably necessary to allow the police to investigate.
What is “brief” will depend on several factors, including: the intrusiveness of the detention, the nature of the suspected criminal offence, the complexity of the investigation, any immediate safety concerns, the ability of police to effectively investigate without detaining you, the lack of police diligence, and/or the lack of immediate availability of the required investigative tools.
You do not have to answer any questions. If you think you are being held illegally, contact a lawyer immediately.