ArrayList に大きなコンテンツを入れることができない可能性があり、そうするとnullになりますか?
32 個の JSONObject を持つ JSONArray を挿入しています。各 JSONObject には名前と電話番号があります。
ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
nvp.add(new BasicNameValuePair("something", content));
public void phoneandname(Context c) {
if (cc.isOnline(c) == true) {
db = new Database(c);
Cursor phones = c.getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
null, null, null);
JSONArray jarray = new JSONArray();
db.open();
while (phones.moveToNext()) {
String name = phones
.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones
.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
db.contact_table(name, phoneNumber);
JSONObject json = new JSONObject();
try {
json.put("name", name);
json.put("phone", phoneNumber);
jarray.put(json);
} catch (JSONException e) {
e.printStackTrace();
}
}
upload(jarray, context);
db.close();
Log.i("********", jarray.toString()); IT SHOWS MY ARRAY AND THEN BEFORE UPLOAD IT TO THE SERVER BY POST IT'S NULL...
phones.close();
}
}
public void upload(Object jobject, Context c) {
ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
DBupload upload = new DBupload();
DatosRegistro dr = new DatosRegistro(c);
nvp.add(new BasicNameValuePair("content", jobject.toString()));
nvp.add(new BasicNameValuePair("token", dr.hash_final(
dr.token_secret(dr.mail(), "mail"), jobject.toString())));
nvp.add(new BasicNameValuePair("id", String.valueOf(dr
.return_id_phone())));
JSONObject json2 = upload.UploaData(nvp,
"http://anonyme.mariomontes.es/contacts/insert");
try {
if (json2.getInt("error") == 1) {
} else {
db.contact_table(name, phoneNumber);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
ありがとう!