无法从mysql服务器

时间:2017-12-06 10:09:28

标签: java android mysql phpmyadmin

我目前正在处理这个项目,但我无法转换它并以HINDI或UTF-8或不同格式检索它。

我在数据库中有以下类型的数据:

१२सालबाà¤|à¤-à¥à¤²à¤°à¤¹à¤¾à¤¹à¥à¤¸à ¤,जयजà¥<शीàà€à‡à¤«à¤°à¥à¤œà¥àล¥¥¥¥¥¥¥ ¤•à¤¾à¤£à¥à¤¡à¤•à¤¾à¤°à¤¾à¤œ...

以印地文格式说: 12सालबादखुलरहाहैसंजयजोशीकेफर्जीसीडीकाण्डकाराज...

在我的php脚本中,当我运行以下脚本时,我得到了这个:

\ u092e \ u094b \ u0906 \ u0925 \ u0924 \ u092d \ u093e \ u0930 \ u0924 \ u0938 \ u0915 \ u0900 \ u094d \ u092f \ u094b \ u0902 \ u0921 \ u0930 \ u0924 \ u093e \ u0939 \ u0948 \ u091a \ u0940 \ u0928? \ u091c \ u093e \ u0928 \ u093f \ u092f \ u092 \ u092a \ u093e \ u0902 \ u091a \ u0935 \ u091c \ u0939 ...

我的php脚本是:

<?php
include('connection.php');

mysql_query('SET CHARACTER SET utf8');

$sth = mysql_query("SELECT DISTINCT Post_title,image_url FROM new_feeds where aprove='1' GROUP BY(Post_title) ORDER BY id DESC");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
    $rows[] = $r;
}

print json_encode($rows);

?>

我需要的是在Android中१२ 12सालबाद。但在android中我的输出是

  

१२सालबाà¤|à¤-à¥à¤²à¤°à¤¹à¤¾à¤¹à¥à¤¸à ¤,जय   à¤œà¥<शीàà€à‡à¤«à¤°à¥à¤œà¥¥à¸à€€àà¡à¥¥¥¥¥¥¥£ A¥à¤¡   à¤•à¤¾à¤°à¤¾à¤œ...

我做错了什么:这是我的android的java文件

dataadapter.java

public class DataAdapter
{
    public String ImageURL;

    public String ImageTitle;

    public String getImageUrl() {

        return ImageURL;
    }

    public void setImageUrl(String imageServerUrl) {

        this.ImageURL = imageServerUrl;
    }

    public String getImageTitle() {

        return ImageTitle;
    }

    public void setImageTitle(String Imagetitlename) {

        this.ImageTitle = Imagetitlename;
    }

}

和主类的方法:

        public void Newsfeed() {
            ImageTitleNameArrayListForClick = new ArrayList<>();

            ListOfdataAdapter = new ArrayList<>();

            recyclerView = (RecyclerView) findViewById(R.id.recyclerView1);

            recyclerView.setHasFixedSize(true);

            layoutManagerOfrecyclerView = new LinearLayoutManager(this);

            recyclerView.setLayoutManager(layoutManagerOfrecyclerView);

            JSON_HTTP_CALL();

            // Implementing Click Listener on RecyclerView.
            recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {

                GestureDetector gestureDetector = new GestureDetector(News.this, new GestureDetector.SimpleOnGestureListener() {

                    @Override public boolean onSingleTapUp(MotionEvent motionEvent) {

                        return true;
                    }

                });
                @Override
                public boolean onInterceptTouchEvent(RecyclerView Recyclerview, MotionEvent motionEvent) {

                    view = Recyclerview.findChildViewUnder(motionEvent.getX(), motionEvent.getY());

                    if(view != null && gestureDetector.onTouchEvent(motionEvent)) {

                        //Getting RecyclerView Clicked Item value.
                        RecyclerViewItemPosition = Recyclerview.getChildAdapterPosition(view);

                        // Showing RecyclerView Clicked Item value using Toast.
                        Toast.makeText(News.this, ImageTitleNameArrayListForClick.get(RecyclerViewItemPosition), Toast.LENGTH_LONG).show();
//                        Intent intent = new Intent(News.this,Feeds.class);
//                        intent.putExtra(AppConstants.NEWS_TAG,ImageTitleNameArrayListForClick.get(RecyclerViewItemPosition).toString());
//                        startActivity(intent);
                    }

                    return false;
                }

                @Override
                public void onTouchEvent(RecyclerView Recyclerview, MotionEvent motionEvent) {


                }

                @Override
                public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

                }
            });

        }

    public void JSON_HTTP_CALL(){

        RequestOfJSonArray = new JsonArrayRequest(HTTP_JSON_URL,

                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {

                        ParseJSonResponse(response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                });

        requestQueue = Volley.newRequestQueue(News.this);

        requestQueue.add(RequestOfJSonArray);
    }

    public void ParseJSonResponse(JSONArray array){

        for(int i = 0; i<array.length(); i++) {

            DataAdapter GetDataAdapter2 = new DataAdapter();

            JSONObject json = null;
            try {

                json = array.getJSONObject(i);

                GetDataAdapter2.setImageTitle(json.getString(Image_Name_JSON));
                // Adding image title name in array to display on RecyclerView click event.
                ImageTitleNameArrayListForClick.add(json.getString(Image_Name_JSON));

                GetDataAdapter2.setImageUrl(json.getString(Image_URL_JSON));



            } catch (JSONException e) {

                e.printStackTrace();
            }
            ListOfdataAdapter.add(GetDataAdapter2);
        }

        recyclerViewadapter = new RecyclerViewAdapter(ListOfdataAdapter, this);

        recyclerView.setAdapter(recyclerViewadapter);
    }

我知道这很奇怪,但我被困在这里。请帮我。谢谢

0 个答案:

没有答案