我完全被困住了。整天用头撞砖墙!
我有一堂课:
public class Main extends Activity.
这有几个按钮。在两个按钮上,我想获得一个布尔函数的结果,该函数检查数据库表是否存在,以便我可以选择下一个操作。
final Button reminderButton = (Button) findViewById(R.id.reminders);
reminderButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
//This is where I want to get the result from the boolean function
// and then either provide a toast msg OR start a new activity
}
});
下面是布尔函数
public boolean isTableExists(SQLiteDatabase db, String tableName) {
if (tableName == null || db == null || !db.isOpen())
{
return false;
}
Cursor cursor = db.rawQuery("SELECT COUNT(*) FROM sqlite_master WHERE type = ?
AND name = ?",new String[] { "table", tableName });
if (!cursor.moveToFirst())
{
return false;
}
int count = cursor.getInt(0);
cursor.close();
return count > 0;
}
在我的一生中,我无法确定要放入我的 onclick 的语法(查看 v){}
我试过
public void onClick(View v)
{
isTableExists(null, null);
}
但我不认为 null,null 是正确的,但是那里有什么论据?
还是我完全走错了路?
感谢您的任何建议