I'm using spring for android. I want to create registration form in my android app. The users maybe fill out the form with utf-8 format but when data send to server and store in MySQL database I find ?????? in my database field.table's column type set to utf8_general_ci. My question is: Do I need to set something for content type in php page OR I need set UTF-8 in my android code? What should I do for both of them? Here is my code that I'm using: I did same as here
File cacheDirectory = context.getFilesDir();
tmpFile = new File(cacheDirectory.getPath() + "/" + "avatar.png");
Resource file = new FileSystemResource(tmpFile);
MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
formData.add("firstName", registerFields[0]);
formData.add("lastName", registerFields[1]);
formData.add("userName", registerFields[2]);
formData.add("file", file);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.MULTIPART_ FORM_DATA);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(formData, requestHeaders);
RestTemplate restTemplate = new RestTemplate(true);
restTemplate.getMessageConverters().add(
new GsonHttpMessageConverter());
restTemplate.getMessageConverters().add(
new StringHttpMessageConverter());
ResponseEntity<Success[]> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity,Success[].class);
return response.getBody();
Edit: Solved problem with UTF-8 I just added this line into my config.php file and problem solved
mysql_query("SET character_set_results=utf8 , character_set_client=utf8 , character_set_connection=utf8 , character_set_database=utf8 , character_set_server=utf8",$con);
Edit: Not solved the problem