I'm make app in android accept the user name in Arabic Language and store in mysql database on the server but the name when send from app to database , it's stored as ???? .
I'm using the charset in database as UTF-8 and all process on the control panel on web is ok m but from app to database it isn't ok
the asyntask for store information from app to db is :
class InsertInfo extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
namest=name.getText().toString();
//emailst=email.getText().toString();
mobilest=mobile.getText().toString();
imgst=image_name;
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", evid+""));
params.add(new BasicNameValuePair("name",namest));
// params.add(new BasicNameValuePair("email", emailst));
params.add(new BasicNameValuePair("mobile", mobilest));
params.add(new BasicNameValuePair("imgurl", imgst));
/* JSONObject json = jsonParser.makeHttpRequest(urlinsert,
"POST", params);*/
try
{
HttpClient httpclient = new DefaultHttpClient();
//HttpParams pa = new BasicHttpParams();
//HttpProtocolParams.setContentCharset(pa, "utf-8");
HttpPost httppost = new HttpPost(urlinsert);
// httppost.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Log.e("pass 1", "connection success ");
}
catch(Exception e)
{
Log.e("Fail 1", e.getMessage());
Toast.makeText(getApplicationContext(), "Invalid IP Address",
Toast.LENGTH_LONG).show();
}
try
{
BufferedReader reader = new BufferedReader
(new InputStreamReader(is,"UTF-8"),8192);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result = sb.toString();
Log.e("pass 2", "connection success ");
}
catch(Exception e)
{
Log.e("Fail 2", e.toString());
}
try
{
JSONObject json_data = new JSONObject(result);
code=(json_data.getInt("code"));
if(code==1)
{
Toast.makeText(getBaseContext(), "Inserted Successfully",
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getBaseContext(), "Sorry, Try Again",
Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
Log.e("Fail 3", e.toString());
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog once product uupdated
}
}
I'm trying a lot of methods and at each all i'm using UTF-8 but it's not work as proper manner , can you help me in this case please :(