Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does query ever return a null cursor

I always see people say that it cursor is never null so you dont need to check for null or not but then there are other people that say that cursor can be null and you chould always check it.

so looking at the query method here it does show that null gets returned so I dont know if I am just missing something or are the people saying that cursor is never null wrong?

do you or do you not need to check if Cursor is null when a query is made?

like image 215
tyczj Avatar asked Jan 10 '23 18:01

tyczj


1 Answers

For ContentResolver queries, yes, the returned Cursor can be null as illustrated by the code you linked.

For SQLiteDatabase queries, no, checking for null Cursor is not necessary. Though it does not hurt much.

like image 55
laalto Avatar answered Jan 17 '23 16:01

laalto