I’m implementing a ContentProvider and when I implement the query method, I’m facing some difficulties.
public final Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
How can I obtain the key value pair of arguments?
Suppose user pass something like “a=? and b=?” and 2,”hello” as selectionArgs, I want to obtain a HashMap {a:2,b:”hello”}.
Here is a program that demonstrates a solution to what you are looking for. Take a close look at the
getHashmap()method which takes a selection string and selection args as arguments and returns a hashmap of what you are looking for. I have used your data set as example. Depending on what you are looking for, it should be a step closer to your solution. The only caveat is that the regular expression will need to be modified if you are going to be using different logical comparisons in addition to ‘=’. Let me know if it works well for you