我无法从以下代码 ::
中检索数据APP在Fetching Block受到攻击。该应用程序正在运行向上获取阻止,但是当它进入获取阻止它没有响应时,模拟器在按下&#34后没有响应; 提交 "按钮。
public void submitButtonClicked(View view) {
eventName= (EditText) findViewById(R.id.eventName);
eventDate= (EditText) findViewById(R.id.eventDate);
sumbitButton= (Button) findViewById(R.id.submit);
System.out.println("Taken data!");
String ename= eventName.getText().toString();
String edate= eventDate.getText().toString();
String dbString;
dbAdapter = new DBAdapter(this);
dbAdapter.open();
try {
dbAdapter.createEvent(ename, edate);
}
catch (SQLException e) {
Toast.makeText(MembersActivity.this, "Some problem occurred",
Toast.LENGTH_LONG).show();
}
System.out.println("Written data to table!");
setContentView(R.layout.event);
System.out.println("With event file!");
//Fetch Block starts here
try {
dbString = dbAdapter.databaseToString();
System.out.println("Fetched data!");
myText.setText(dbString);
myText.setText(" ");
}
catch (Exception e){
System.out.println("Problem in Fetching data!");
e.printStackTrace();
}
}
函数databaseToString位于下面 ::
//Print out the database as a string
public String databaseToString() {
String dbString="";
mDbHelper = new DBHelper(mCtx);
SQLiteDatabase db = mDbHelper.getReadableDatabase();
String query="select * from events where 1";
//Cursor point to a location in your results
Cursor c = db.rawQuery(query,null);
//Move to the first row in your results
c.moveToFirst();
while(!c.isAfterLast()){
if(c.getString(c.getColumnIndex("eventname"))!= null){
dbString+=c.getString(c.getColumnIndex("eventname"));
//dbString+=c.getString(c.getColumnIndex("eventdate"));
dbString+="\n";
}
}
db.close();
return dbString;
}