How Can a Defendant Get Out of Jail?

Someone who is arrested has been accused of a crime. They are legally considered innocent until proven guilty in court, but their trial in court may not happen for some time after their arrest. What happens to the accused during this time? It is not fair to keep the accused in custody unless they are considered danger to the community,