English 中文(简体)
• 如何获得所有在甲状腺中的网络服务许可?
原标题:How to get all permissions for web service in android?

I have created an android application using java, php(backend) and mysql(database). I have placed my backend php code and the database on Linux hosting server. My problem is that I can only read the data from the database, i.e., my application can fetch the data from the server, but it couldn t make any changes to the fetched data and also I get errors when I run using the server, but when I placed the database and code in local system it works perfectly on the localhost, but when placed in server it can only read the data but not insert, update or delete the data. I have already given full privileges to the database in the server. Can anyone please help me regarding this aspect? I think the server doesn t accept requests from outsider like mobile. So my question is

what do we need to do such that the server accepts requests from mobile side?

PS:我对服务器数据库给予了充分的特权,我还在海底清单中增加了因特网许可。

@Lie 瑞安 根据您的要求,我在此将服务器连接起来。

 protected List<List<String>> callWebServer(String queryString, String statement){

    List<List<String>> stringList = null;
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("query", queryString));
    nameValuePairs.add(new BasicNameValuePair("statement", statement));

    try{
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(WEB_SERVICE_URL);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httppost,responseHandler);
        JSONObject json = new JSONObject(responseBody);

        if(statement.equals(DB_SELECT_STATEMENT) || statement.equals(DB_INSERT_STATEMENT)){

            List<String> queryStrings = null;
            // parsing query 
            if(statement.equals(DB_SELECT_STATEMENT)){
                queryStrings = splitQuery(queryString);


            JSONArray jArray = json.getJSONArray("output");

            if(jArray.length() > 0)
                stringList = new ArrayList<List<String>>();

            for(int i=0;i<jArray.length();i++){
                JSONObject json_data = jArray.getJSONObject(i);

                String rowData = json_data.getString("rowData");
                if(rowData.equals("nothing")){
                //  Toast.makeText(getBaseContext(), "No record found", Toast.LENGTH_LONG).show();
                }else{

                    JSONObject getClassNameObject = new JSONObject(rowData);
                    List<String> tempStringList = new ArrayList<String>();

                    for(String valueStr:queryStrings){
                        if(valueStr.contains(".")) valueStr = valueStr.split("\.")[1];
                        tempStringList.add(getClassNameObject.getString(valueStr));
                    }

                    stringList.add(tempStringList);
                }
            }
            }else{
                JSONArray jArray = json.getJSONArray("output");
                stringList = new ArrayList<List<String>>();
                JSONObject json_data = jArray.getJSONObject(0);

                stringList.add(getList("mn", json_data.getString("rowData")));

            }
        }

        //Toast.makeText(getBaseContext(), "Event Added Successfully", Toast.LENGTH_LONG).show();
    }catch(ArrayIndexOutOfBoundsException e){

    }catch(Exception e){

        Log.e("log_tag", "Error in http connection:"+e.toString());
    }

而处理请求的《加拿大刑法》是:

 <?php
include "connect.php";

if($_POST["statement"] == "select"){

    $booleanRow = true;
    // for select statements
    $db_output = mysql_query($_POST["query"]));
    while($row=mysql_fetch_array($db_output, MYSQL_ASSOC)){
        $output[] = array( rowData =>$row);
        $booleanRow = false;            
    }       

    if($booleanRow){
        $row = "nothing";
        $output[] = array( rowData =>$row);
    }

    print(json_encode(array( output =>$output)));
}else{

    // for insert, update and delete       
    mysql_query($_POST["query"]);   

    $row = mysql_insert_id();       
    $output[] = array( rowData =>$row);
    print(json_encode(array( output =>$output)));
}

 mysql_close($link);
  ?>

预付款。

问题回答

为了允许申请开放网络,你需要打上roid子。 许可。 INTER(AndroidManifest.xml)

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

更多许可清单见Manifest.Permission





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签