私は、phpを使ってMySQLデータベースをAndroidに接続する際のさまざまなウェブサイトにあるチュートリアルを試しています。私は以下のコードで何が間違っているのかわかりません。誰も私が何をする必要があるか教えてもらえますか?残念ながら、都市が停止した LOGCAT、IN'/data/anr/traces.txt':許可が拒否されました
::1月17日02:57:18.790:E/dalvikvm(325):この問題IHAVE
「スタック・トレース・ファイルを開くことができません/データ/ ANR/traces.txt ':許可は、これは私のPHPコード
<?php
mysql_connect("localhost","???????????","......;");
mysql_select_db("???????????");
$sql=mysql_query("select * from users");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>
city.java
package com.android.City;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListActivity;
import android.net.ParseException;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class city extends ListActivity {
JSONArray jArray;
String result = null;
InputStream is = null;
StringBuilder sb=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.estm2011.org/check.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
//paring data
String login;
String pass;
try{
jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++){
json_data = jArray.getJSONObject(i);
login=json_data.getString("LOGIN");
pass=json_data.getString("PASSWORD");
}
}
catch(JSONException e1){
Toast.makeText(getBaseContext(), "No City Found" ,Toast.LENGTH_LONG).show();
} catch (ParseException e1) {
e1.printStackTrace();
}
}
}
0123で を否定あなたは、ファイルのパーミッションをチェックするために内部のフォルダ/data/anr
にadb
シェルを使用することができます
のmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.City"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".CityActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
あなたの問題を明確にするためにDDMSからログを投稿できますか? – Piyush
重複可能[スタックトレースファイル '/data/anr/traces.txtを開くことができません':許可が拒否されました](http://stackoverflow.com/questions/8102719/unable-to-open-stack-trace-file- data-anr-traces-txt-permission-denied) – PearsonArtPhoto
これはプログラムの実際の問題ではありませんが、クラッシュレポートサブシステムの厄介な構成バグです。実際の問題を見つけて修正するには、logcatを使用してください。他のプログラムがクラッシュした場合でも、この問題があなたのプログラムのために見られることはありません。 –