I am trying to get it to accept the accent marks but no one has managed to solve this problem for me, it does not directly read the letters with accent marks, therefore the only solution that I think is simpler is that if you enter an accent mark, it will change it for the same one without an accent mark, it is say, "á" for "a", "é" for "e" ... and so on.
I'm going to help you too because I found this code that does what I'm telling you, but I don't know how to put it in my code.
Character change example:
public static String remove1(String input) {
// Cadena de caracteres original a sustituir.
String original = "áàäéèëíìïóòöúùuñÁÀÄÉÈËÍÌÏÓÒÖÚÙÜÑçÇ";
// Cadena de caracteres ASCII que reemplazarán los originales.
String ascii = "aaaeeeiiiooouuunAAAEEEIIIOOOUUUNcC";
String output = input;
for (int i=0; i<original.length(); i++) {
// Reemplazamos los caracteres especiales.
output = output.replace(original.charAt(i), ascii.charAt(i));
}//for i
return output;
}
That is what I have found on the Internet, one of many, but my code is this (and it does work):
public class Admin extends AppCompatActivity {
EditText titulo_in;
EditText descripcion_in;
Button btnActualizarA;
String recuperado="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.admin);
titulo_in = (EditText)findViewById(R.id.titulo_in);
descripcion_in = (EditText)findViewById(R.id.descripcion_in);
// titu = titulo_in.getText().toString();
//desc = descripcion_in.getText().toString();
final Bundle recupera=getIntent().getExtras();
if(recupera!=null){
recuperado=recupera.getString("cod");
}
btnActualizarA=(Button)findViewById(R.id.publicar);
btnActualizarA.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Thread tr2=new Thread(){
@Override
public void run() {
ActualizarPost(recuperado, titulo_in.getText().toString(), descripcion_in.getText().toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),"Se ha completado la publicación", Toast.LENGTH_SHORT).show();
}
});
}
};
tr2.start();
}
});
}
public void ActualizarPost(String c, String tit, String des){
// HttpURLConnection conection=null;
try{
String titleUtf8 = URLEncoder.encode(tit, "UTF-8").replaceAll("\\+","%20");
String descriptionUtf8 = URLEncoder.encode(des, "UTF-8").replaceAll("\\+","%20");
String urlParameters="cod="+c+"&tit="+titleUtf8+"&des="+descriptionUtf8;
URL url=new URL("http://rudeboys.esy.es/ramiroconnect/publicar.php");
HttpURLConnection conection = (HttpURLConnection) url.openConnection();
// conection.setRequestProperty("Content-Type","UTF-8");
//estableciendo el metodo
conection.setRequestMethod("POST");
//longitud de datos que se envian
conection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
// conection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
//comando para la salida de datos
conection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(conection.getOutputStream());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
writer.write(urlParameters);
writer.close();
InputStream is =conection.getInputStream();
}catch (Exception ex){}
}
}
How can I change the code so that it updates the data in the DB without accents?
You can create a function that changed the tildes, like the following:
Example
And the log will say: "oooooliiiii teenii pololi"
Well, to use what you put as an example you have to use:
This way you will be updating the value without accents.