If police do have reasonable and probable grounds to detain you and you are arrested and taken into custody, police can detain you for 24 hours. This 24-hour period may be extended if you are arrested on a holiday or on the weekend.
Within this 24-hour time period, they must either release you or bring you before a judge or justice of the peace and be prepared to show just cause as to why you should be held in custody. It is at this stage that it is essential to have the services of a lawyer to advocate for you. Often times a lawyer can negotiate with the crown to consent to your release, sometimes with certain conditions and with or without a surety depending on the specifics of your case and your individual circumstances. Otherwise the lawyer can schedule a contested bail hearing in front of a justice at the earliest possible time with the court.
If you are denied bail after a contested hearing you will be held in custody until a successful bail review is held if you and your counsel decide it is a viable option. If a bail review does not occur or your bail review is unsuccessful, the court can continue to detain you until your trial date.
You have a right to not be arbitrarily detained. Unless the police have objectively reasonable and probable grounds to detain you for investigative purposes or grounds to believe you have committed a crime, they cannot detain you.