我有一个数据库,我打开它并用游标提取我需要的查询。如何检查我提取的变量是 int 还是 string?因为我不知道我要打开哪张桌子,所以一切都是动态的。所以我不能使用cursor.getString()
或cursor.getInt()
编辑
对不起我的英语不好,我是意大利人
找到了。此方法有效:
public boolean isInt(String s){
boolean result=false;
try{
Integer.parseInt(s);
result=true;
}catch(Exception e){
}
return result;
}
这应该会有所帮助: http: //developer.android.com/reference/android/database/Cursor.html#getType (int )
将列索引传递给它。它应该返回您其中之一