I am developing my Android application for Android now, I use several tables to receive and insert data. during development and found that I get data from a table, it has only two columns STATS(_id, stat_name). What is my problem? I have activity with 10 buttons, and each button correlates with one stat_name. When users click one of the buttons, the application "goes" to the table STATSto get the correct one _id, and then enters this _idon the other table GAME_STATS(_id, PlayerId (fk), GameId(fk), StatsId(fk)(andmore))on STATS._id = GAME_STATS.StatsId, and I usually have to perform a similar operation for PlayerId.
Now I am doing this:
public String getStatId(String statName){
String statId = "Error";
Cursor c = mDb.query(STAT_TABLE, new String[] {AbstractDbAdapter.STAT_ID, AbstractDbAdapter.STAT_NAME}, AbstractDbAdapter.STAT_NAME+ " = " +statName, null, null, null, null);
int count = c.getCount();
if(count == 1){
c.moveToFirst();
statId = c.getString(c.getColumnIndex(AbstractDbAdapter.STAT_ID));
}
c.close();
mDb.close();
Log.d("FootballApp","StatId =" +statId);
return statId;
}
, , , Cursor . , , , , . 9 , , _id , , , .
- , ? :)
!:)