Detention centers are used as follows: (1) for the detention of persons committed in order to secure their attendance as witnesses in criminal cases; (2) for the detention of persons charged with crime and committed for trial; (3) for the confinement of persons committed for contempt or upon civil process or by other authority of law; (4) for the confinement of persons sentenced to imprisonment therein upon conviction of a crime; (5) for the confinement of persons sentenced to the state prison, as agreed upon by the state and the administrator in charge of the detention center.