Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blob query with InexactContentUti #37

Closed
tasomaniac opened this issue Oct 4, 2015 · 11 comments
Closed

blob query with InexactContentUti #37

tasomaniac opened this issue Oct 4, 2015 · 11 comments

Comments

@tasomaniac
Copy link

I have a BLOB column in my database that I use it to store boolean values.

ContentValues class accepts true/false as a direct parameter and stores them as 1 and 0 in the database. When I query normally, I have to like this WHERE PREFERRED=1. When I use selectionArgs and send new String[] {"1"} it returns an empty Cursor.

The same thing is happening to the below query. I sends "1" as the parameter using selectionsArgs and the result is always empty.

        @InexactContentUri(
                name = "OPENWITH_PREFERRED",
                path = OpenWithDatabase.OPENWITH + "/preferred/#",
                type = "vnd.android.cursor.dir/openwith",
                whereColumn = PREFERRED,
                pathSegment = 2)
        public static Uri preferred() {
            return Uri.withAppendedPath(CONTENT_URI, "preferred/1");
        }

At the end, I couldn't find any way to query boolean columns using @InexactContentUri

I hope I will be understood. I don't know if this is a bug or not. I just wanted you to know it.

@SimonVT
Copy link
Owner

SimonVT commented Oct 6, 2015

So if you query the database yourself it doesn't work either?

@tasomaniac
Copy link
Author

It works in the classic way when I query the dB with contentresolver. But
InexactContentUri is cool to use.

On Tue, Oct 6, 2015, 7:09 PM Simon Vig Therkildsen notifications@github.com
wrote:

So if you query the database yourself it doesn't work either?


Reply to this email directly or view it on GitHub
#37 (comment).

@tasomaniac
Copy link
Author

I just wanted to see your opinion.

On Tue, Oct 6, 2015, 9:06 PM Said Tahsin Dane tasomaniac@gmail.com wrote:

It works in the classic way when I query the dB with contentresolver. But
InexactContentUri is cool to use.

On Tue, Oct 6, 2015, 7:09 PM Simon Vig Therkildsen <
notifications@github.com> wrote:

So if you query the database yourself it doesn't work either?


Reply to this email directly or view it on GitHub
#37 (comment).

@SimonVT
Copy link
Owner

SimonVT commented Oct 6, 2015

Well, for your example I wouldn't use @InexactContentUri, I'd just use @ContentUri and define the where parameter.

@tasomaniac
Copy link
Author

Oh I thought there can be only a single @ContentUri in a class. I couldn't
annotate a method with it. And your sample project as well has only one.

Can I just add another @ContentUri?

On Tue, Oct 6, 2015, 9:17 PM Simon Vig Therkildsen notifications@github.com
wrote:

Well, for your example I wouldn't use @InexactContentUri, I'd just use
@ContentUri and define the where parameter.


Reply to this email directly or view it on GitHub
#37 (comment).

@SimonVT
Copy link
Owner

SimonVT commented Oct 6, 2015

Sure, you can have all the @ContentUri annotated fields you want :)

@tasomaniac
Copy link
Author

Do they have to be fields? Not methods?

On Tue, Oct 6, 2015, 10:45 PM Simon Vig Therkildsen <
notifications@github.com> wrote:

Sure, you can have all the @ContentUri annotated fields you want :)


Reply to this email directly or view it on GitHub
#37 (comment).

@SimonVT
Copy link
Owner

SimonVT commented Oct 7, 2015

Yes, the @ContentUri Uri never changes, so that's just for static fields. @InexactContentUri is used when the Uri is created based on some value (e.g. an id).

@tasomaniac
Copy link
Author

It seems that I can do what I need using @ContentUri.
@IntexactContentUri with blobs do not work. If it is ok, we can close this issue.

@SimonVT
Copy link
Owner

SimonVT commented Oct 7, 2015

@InexactContentUri works fine with blobs, your @InexactContentUri and @ContentUri just aren't querying the same thing. If you care you can attach a debugger and find out what is being passed to SQLiteDatabase#query in the two cases, to see what the difference it.

@SimonVT SimonVT closed this as completed Oct 7, 2015
@tasomaniac
Copy link
Author

Yes it did. Thank you very much.

Little bit documentation on @InexactContentUri and @ContentUri would be really helpfull. I want to help. Sending a PR now. If you don't like it, you can add your own.

Thank you for the great lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants