Bonjour,

Me voila lancé dans le développement d'application android.

Je développe une application utilisant une BDD. J'ai réussi à la faire fonctionne sur l'émulateur. Mais pas sur mon télèphone, j'ai une belle exception.
Je pense que je doit crée la base sur le télèphone, la 1er fois. Il y a t'il un mécanisme à respecter ?

J'utilise cette classe là, dans mon activité. Je l'instancie et ouvre pour l'accès à la lecture/écriture.

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
public class BddAdapt {
 
	private static final int BASE_VERSION = 1;
	private static final String BASE_NOM = "verbes.db";
 
	private static final String TABLE_VERBES = "table_verbes";
 
	private static final String COLONNE_ID = "id";
	private static final int COLONNE_ID_ID = 0;
	private static final String COLONNE_INF ="inf";
	private static final int COLONNE_INF_ID= 1;
	private static final String COLONNE_PRET = "pret";
	private static final int COLONNE_PRET_ID= 2;
	private static final String COLONNE_PARTPASS = "partpass";
	private static final int COLONNE_PARTPASS_ID= 3;
	private static final String COLONNE_TRAD = "trad";
	private static final int COLONNE_TRAD_ID= 4;
	private static final String[] REQ_ALLCOLONNE = {COLONNE_ID,COLONNE_INF,COLONNE_PRET,COLONNE_PARTPASS,COLONNE_TRAD}; 
 
 
	private SQLiteDatabase maBDD;
	private BDD bddHelper;
 
	public BddAdapt(Context context) {
		// TODO Auto-generated constructor stub
		bddHelper = new BDD(context, BASE_NOM,null,BASE_VERSION);
//		this.open();
//		bddHelper.onCreate(maBDD);
	}
 
	public SQLiteDatabase open(){
		maBDD = this.bddHelper.getWritableDatabase();
		return this.maBDD;
	}
 
	public void close()
	{
		this.maBDD.close();
 
	}
	public String colonneModif(String[] allColonne){
		String req = "";
 
		for(int i=0;i<allColonne.length;i++){
			req+=allColonne[i];
			if(i !=allColonne.length-1 )
			req+=",";
		}
		return req;
	}
	public long Insert(Verbes v){
 
		ContentValues cv = new ContentValues();
		cv.put(COLONNE_INF,v.getInf());
		cv.put(COLONNE_PARTPASS,v.getPartPass());
		cv.put(COLONNE_PRET,v.getPret());
		cv.put(COLONNE_TRAD,v.getTrad());
		return this.maBDD.insert(TABLE_VERBES,null,cv);
 
//		String sql = "INSERT INTO "+TABLE_VERBES+" ("+colonneModif(REQ_ALLCOLONNE)+") VALUES ("+null+","+v.getInf()+","+v.getPret()+","+v.getPartPass()+","+v.getTrad()+")" ;
//		
//		this.maBDD.execSQL(sql);
	}
	private Verbes cursorToVerbe(Cursor c){
 
		if(c.getCount()==0){
			return null;
		}
		Verbes v = new Verbes();
		v.setInf(c.getString(COLONNE_INF_ID));
		v.setPartPass(c.getString(COLONNE_PARTPASS_ID));
		v.setPret(c.getString(COLONNE_PRET_ID));
		v.setTrad(c.getString(COLONNE_TRAD_ID));
		v.setId(c.getInt(COLONNE_ID_ID));
 
		c.close();
 
		return v;
	}
	public Verbes getVerbesByTrad(String trad){
		//String[] args = new String[] {COLONNE_ID,COLONNE_INF,COLONNE_PRET,COLONNE_PARTPASS,COLONNE_TRAD};
		Cursor c =this.maBDD.query(TABLE_VERBES, new String[] {COLONNE_ID,COLONNE_INF,COLONNE_PRET,COLONNE_PARTPASS,COLONNE_TRAD},COLONNE_TRAD+" LIKE "+trad , null,null, null,null);
		//Cursor c =this.maBDD.query(TABLE_VERBES,new String[] {COLONNE_ID,COLONNE_INF,COLONNE_PRET,COLONNE_PARTPASS,COLONNE_TRAD},null,null, null,COLONNE_TRAD+" LIKE "+trad, null);
		//Cursor c = this.maBDD.query(TABLE_VERBES, args, null, null,null,COLONNE_TRAD+" LIKE "+trad,null);
		return cursorToVerbe(c);
	}
 
	public Verbes getVerbesById(int id){
 
		Cursor c = this.maBDD.query(TABLE_VERBES, REQ_ALLCOLONNE, null, null,null,COLONNE_ID+" = " +id,null);
		return cursorToVerbe(c);
	}
 
	public ArrayList<Verbes> getAllVerbes()
	{
		Cursor c = this.maBDD.query(TABLE_VERBES, REQ_ALLCOLONNE, null, null,null,null,null);
		return cursorToAllVerbes(c);
	}
	private ArrayList<Verbes> cursorToAllVerbes(Cursor c) {
		// TODO Auto-generated method stub
		if(c.getCount() == 0){
			return new ArrayList<Verbes>(0);
		}
		ArrayList<Verbes> list = new ArrayList<Verbes>(c.getCount());
 
		c.moveToFirst();
		do{
			Verbes v = new Verbes();
			v.setId(c.getInt(COLONNE_ID_ID));
			v.setInf((c.getString(COLONNE_INF_ID)));
			v.setPartPass(c.getString(COLONNE_PARTPASS_ID));
			v.setPret(c.getString(COLONNE_PRET_ID));
			v.setTrad(c.getString(COLONNE_TRAD_ID));
			list.add(v);
		}while(c.moveToNext());
		c.close();
 
		return list;
	}
 
	public SQLiteDatabase getMaBDD() {
		return maBDD;
	}
}
Ensuite, j'aimerais avoir plus de précision sur les layouts. J'ai beaucoup de mal à les utilisés ?! On peut mettre Plusieurs LinearLayout dans le LinearLayout ?
Je voudrez découper mon activité en plusieurs partie, je pensais le faire avec des LinearLayout. Mais dans le 3éme, je n'arrive pas a placer mes composants .. !

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
<?xml version="1.0" encoding="utf-8"?>
 
 
 
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
 
<LinearLayout android:id="@+id/LinearLayout03" android:layout_width="wrap_content" android:layout_height="wrap_content"></LinearLayout>
 
<LinearLayout android:id="@+id/LinearLayout02" android:gravity="center" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_gravity="center|center_horizontal|top">
<TextView android:id="@+id/TextView01" android:text="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center|top" android:layout_gravity="center|top"></TextView></LinearLayout>
 
 
 
 
 
 
</LinearLayout>
Merci d'avance