java——getString(1)在从数据库获取信息方面意味着什么?
发布时间:2022-04-06 23:54:00 713
相关标签: # php
这里有一个关于从数据库读取数据的教程。我的问题是:
getString中的数字是否表示方法从中获取字符串的字段?
方法如下:
public ArrayList readCourses() {
// on below line we are creating a
// database for reading our database.
SQLiteDatabase db = this.getReadableDatabase();
// on below line we are creating a cursor with query to read data from database.
Cursor cursorCourses = db.rawQuery("SELECT * FROM " + TABLE_NAME, null);
// on below line we are creating a new array list.
ArrayList courseModalArrayList = new ArrayList<>();
// moving our cursor to first position.
if (cursorCourses.moveToFirst()) {
do {
// on below line we are adding the data from cursor to our array list.
courseModalArrayList.add(new CourseModal(cursorCourses.getString(1),
cursorCourses.getString(4),
cursorCourses.getString(2),
cursorCourses.getString(3)));
} while (cursorCourses.moveToNext());
// moving our cursor to next.
}
// at last closing our cursor
// and returning our array list.
cursorCourses.close();
return courseModalArrayList;
}
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报