我正在使用eclipse jsp和mysql开发一个Android应用程序。在这里我需要在正确的标签下显示android布局中特定表的所有行(例如:我在mysql中有一个名为demo的表,其中包含字段ID名称和地址,我希望在android中显示所有的demo表行表格式(id,name,address))。我怎么能用jsp和android做到这一点?有人请帮助我。
答案 0 :(得分:0)
使用数组列表和bean类来获取和显示您想要显示的数据
public ArrayList<SigninBean> getUser() {
// onCreate(getWritableDatabase());
SigninBean sBean = new SigninBean();
ArrayList<SigninBean> arList = new ArrayList<>();
// String selectQuery = "SELECT * FROM " + TABLE_Name + " WHERE "
// + KEY_DATE + " = ?";
// String[] args={tag};
SQLiteDatabase db = this.getReadableDatabase();
String query = "SELECT * FROM " + TABLE;
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst()) {
while (cursor.isAfterLast() == false) {
String d = cursor.getString(cursor.getColumnIndex(COLUMN_signin_date));
String photo = cursor.getString(cursor.getColumnIndex(COLUMN_signin_photo));
String gender = cursor.getString(cursor.getColumnIndex(COLUMN_signin_gender));
String time = cursor.getString(cursor.getColumnIndex(COLUMN_signin_time));
String accurate = cursor.getString(cursor.getColumnIndex(COLUMN_Signin_accurate));
String name = cursor.getString(cursor.getColumnIndex(COLUMN_signin_name));
String city = cursor.getString(cursor.getColumnIndex(COLUMN_signin_city));
String country = cursor.getString(cursor.getColumnIndex(COLUMN_signin_country));
sBean.setName(name);
sBean.setPhoto(photo);
sBean.setTime(time);
sBean.setGender(gender);
sBean.setCity(city);
sBean.setCountry(country);
sBean.setDate(d);
sBean.setAccurate(accurate);
Log.e("User values r=========>", "" + d + " " + name + " " + city + " " + country + " " + d);
cursor.moveToNext();
arList.add(sBean);
}
}