我必須從android工作室瞭解一些java代碼,但由於我是Java和android的新手,我有一個問題。什麼是光標,它在做什麼(在這種情況下)?
任何人都知道Cursor實際上是什麼,它在這種情況下究竟做了什麼?
private Movie cursorToMovie (Cursor cursor)
{
Movie movie = new Movie();
movie.setId(cursor.getInt(0));
movie.setName(cursor.getString(1));
movie.setGenre(cursor.getString(2));
movie.setYear(cursor.getInt(3));
movie.setSynopsis(cursor.getString(4));
return movie;
}
public List<Movie> getAllMovies()
{
open();
List<Movie> movieList = new ArrayList<>();
Cursor cursor = db.query(Movie.TABLE_NAME, MovieAllColumns, null, null, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast())
{
Movie movie = cursorToMovie(cursor);
movieList.add(movie);
cursor.moveToNext();
}
cursor.close();
close();
return movieList;
}
您添加了android-cursor標籤,但未能讀取其信息? –
你知道Google嗎? –