我的问题是通过查看光标可以知道一个字段是表的主键。或者我们如何知道哪个字段是主键?
我想写一个这样的课。所以我必须以编程方式学习它
public class BO {
private HashMap<String, Object> data;
private String primaryKey="";
public BO() {
data=new HashMap<String, Object>();
}
public String getUpdateQuery() {
return null;
}
public String getInsertQusery() {
return null;
}
public String getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
}
public int getLogicalReference() {
return logicalReference;
}
public void loadDataFromCursor(Cursor cur){
String[] fields=cur.getColumnNames();
for(int i=0;i<fields.length;i++){
switch (cur.getType(i)) {
case Cursor.FIELD_TYPE_INTEGER:
data.put(fields[i], cur.getInt(i));
break;
default:
break;
}
}
}
public void setLogicalReference(int logicalReference) {
this.logicalReference = logicalReference;
}
}