Bonsoir à tous,

Je voudrais récupérer des données extraites à partir de ma BDD mysql sous forme d'une liste. Lorsque j'ai testé mon programme avec le login et le mot de passe relatifs au premier utilisateur situé dans ma table user ça marchait. Mais si je teste avec d'autres utilisateurs ça provoque un force close de l'application avec cette exception: java.lang.NullPointerException au niveau de cette ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
JSONArray  offres_e = json.getJSONArray("offres_enregistrees");
Le LogCat m'affiche également cette erreur: 04-11 20:56:41.883: E/log_tag(297): Error parsing data org.json.JSONException: A JSONObject text must begin with '{' at character 1 of <br />

Ci-après mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.projet.tmjob;
 
import java.util.ArrayList;
import java.util.HashMap;
 
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.app.ListActivity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
 
public class OffresEnregistrees extends ListActivity {
	private static final String MY_PREFERENCES = "mespreferences";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	SharedPreferences sharedPreferences = getSharedPreferences(MY_PREFERENCES, 0);
        String id = sharedPreferences.getString("id", "");
        super.onCreate(savedInstanceState);
        ArrayList<NameValuePair> identifiant = new ArrayList<NameValuePair>();
		identifiant.add(new BasicNameValuePair("id", id));
        setContentView(R.layout.list_enregist);
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
        JSONObject json = JSONfunctions.getJSONUrlParam("http://10.0.2.2/mesRequetes/off_enregistrees.php", identifiant);
        try{
        	JSONArray  offres_e = json.getJSONArray("offres_enregistrees");
	        for(int i=0;i<offres_e.length();i++){						
				HashMap<String, String> map = new HashMap<String, String>();	
				JSONObject o = offres_e.getJSONObject(i);
 
	        	map.put("poste", "Poste:" + o.getString("poste"));
	        	map.put("idoff", o.getString("idoff"));
	        	mylist.add(map);
	        	Log.i("log_tag","Poste:"+o.getString("poste")+ 
						", Numero de l'offre:"+o.getString("idoff")
						);
			}		
        }catch(JSONException e)        {
        	 Log.e("log_tag", "Error parsing data "+e.toString());
        }
 
        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.off_enregistrees, 
                        new String[] { "poste", "idoff" }, 
                        new int[] { R.id.TV_poste, R.id.TV_idoffre });
 
        setListAdapter(adapter);
        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);	
  }
}
Merci de m'aider