TL;DR
Nick Moore's answer explains the meaning correctly. Now that you've clarified your confusions, I'd like to point out some important points, based on your misunderstandings:
- If your
whereClause
causes the function to delete one row, it will return 1.
- If you delete all rows (by passing
"1"
to whereClause
), it will return the number of all rows that were deleted.
- What if you do that (deleting all rows by passing
"1"
to whereClause
), and the table has only one row (which means, it will delete just 1 row in total), will it still return 1? Yes, it will return 1. (Given that it works as stated.)
Reading comprehension:
Let's have a closer look at the sentences.
@return
the number of rows affected if a whereClause
is passed in, 0 otherwise.
You can read @return
in Javadoc documents (I presume) as "This method returns"; so it's "the method delete()
returns ..." in our example.
It returns what? The sentence states the conditions in the pattern [ X if A-condition, Y otherwise ]. In other words, if A-condition applies, it returns X; otherwise, it returns Y.
So, this sentence means: If a whereClause
is passed in, delete()
returns the number of rows affected; otherwise (i.e. you do not specify a proper whereClause
), it returns 0.
To remove all rows and get a count pass "1" as the whereClause
.
I think the sentence would be clearer with a comma:
To remove all rows and get a count, pass "1" as the whereClause
.
In other words,
To remove all rows and get a count pass "1" as the whereClause
.
(= Pass "1" as the whereClause
to remove all rows and get a count.)
This does not say what you understand ("if you delete all rows, the delete method will return 1"). It says, "To remove all rows, pass a string "1"
as your whereClause
". For example, this will remove all rows: delete(myTable, "1", myWhereArgs);
By doing so (deleting all rows by passing "1"
as the whereClause
), you will get "a count" as the return value. That is, delete()
will delete all rows, and then return the count of all deleted rows.
So, what if we delete just one row, will it still return 1? Yes, it will return 1.