I'm developing an android application that connects to a database online to get data from it and populate a ListView. I'm using a php page to get the information, the data is encoded using json. The database contains arabic letters, but they're not encoded well, they're showed as following : "???????".
The java code is :
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//httpclient = new DefaultHttpClient();
httpclient = new DefaultHttpClient();
String type2="car";
httppost = new HttpPost("http://www.mypage.com/myfolder/mypage.php?Username="+type2+"");
try
{
    nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("Type",type));
    nameValuePairs.add(new BasicNameValuePair("Date",date));
    nameValuePairs.add(new BasicNameValuePair("Title",title));
    nameValuePairs.add(new BasicNameValuePair("Content",content));
    nameValuePairs.add(new BasicNameValuePair("Time",time));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));
    response = httpclient.execute(httppost);
    if(response.getStatusLine().getStatusCode()==200)
    {
        entity=response.getEntity();
        if(entity !=null)
        {
            InputStream instream=entity.getContent();
            try
            {
                JSONArray jArray = new JSONArray(convertStreamToString(instream));
arr=jArray;
                //  int jArrayLength = arr.length();
                postsinarray = new String[arr.length()];
                arrayinlist=new String[arr.length()];
                //final List<String> listContents = new ArrayList<String>(jArrayLength);
                //thelist=listContents;
            }
            catch(JSONException e)
            {
            }
        }
    }
}//End of first try
catch(Exception e)
{
    // Toast.makeText(getBaseContext(),"CONNECTION ERROR",Toast.LENGTH_LONG).show();
}
The php code is :
<?php
//ini_set('default_charset','utf-8');
//header('content-type:text/html;charset=utf-8');
$host="myhost";
$user="myuser";
$pass="mypass";
$dbname="mydb";
$Username=$_GET['Username'];
$con= mysql_connect($host,$user,$pass);
$BD= mysql_select_db($dbname, $con);
$query=mysql_query("select * from Todolist where Username='".$Username."' ORDER BY Date DESC");
$num=mysql_num_rows($query);
//echo phpversion();
if($num>=1)
{
    $output=array();
    while($list=mysql_fetch_assoc($query))
    {
        $output[]=$list;
    }
    echo json_encode($output,JSON_UNESCAPED_UNICODE);
    mysql_close();
}
else
{
    echo "error";
}
?>
Any help please ?
 
     
    