Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Sook Yee Lim
Sook Yee Lim
30 Points

inputting parameters for my resolver.query

Hi I created this app called database_2(contentprovider) and another app database_3 to access the the number of shapes, width, height, and radius in database_2 using content resolver.So far, I I only got this ContentResolver resolver=getContentResolver(); Cursor mCursor=resolver.query(SchemeShapes.Shape.CONTENT_URI,.param2,param3...)

public class SchemeShapes { public static final String CONTENT_AUTHORITY = "edu.monash.fit2081.db.provider";

//Content URIs will use the following as their base
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);


public static final class Shape {
    //building a content URI for the shapes table
    //A path that points to the shapes table
    public static final String PATH_VERSION = "shapes";
    // Content Uri = Content Authority + Path (shapes in this case)
    public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_VERSION).build();


    //Table name
    public static final String TABLE_NAME = "shapes";

    //Table Column names
    public static final String ID = "_id"; //CursorAdapters will not work if this column with this name is not present
    public static final String SHAPE_NAME = "shape_name";
    public static final String SHAPE_TYPE = "shape_type";
    public static final String SHAPE_X = "shape_x";
    public static final String SHAPE_Y = "shape_y";
    public static final String SHAPE_WIDTH = "shape_width";
    public static final String SHAPE_HEIGHT = "shape_height";
    public static final String SHAPE_RADIUS = "shape_radius";
    public static final String SHAPE_BORDER_THICKNESS = "shape_border_thickness";
    public static final String SHAPE_COLOR = "shape_color";

    // To prevent someone from accidentally instantiating the contract class, make the constructor private.
    private Shape(){}

    public static final String[] PROJECTION = new String[]{
            Shape.ID,
            Shape.SHAPE_NAME,
            Shape.SHAPE_TYPE,
            Shape.SHAPE_X,
            Shape.SHAPE_Y,
            Shape.SHAPE_WIDTH,
            Shape.SHAPE_HEIGHT,
            Shape.SHAPE_RADIUS,
            Shape.SHAPE_RADIUS,
            Shape.SHAPE_BORDER_THICKNESS,
            Shape.SHAPE_COLOR
    };
}

}

Steven Parker
Steven Parker
231,127 Points

This is clearly not SQL. You might get more/quicker responses if you move the topic to the one for the language.

Sook Yee Lim
Sook Yee Lim
30 Points

But it is under databases.I'm asking how to write my selection arguments and my where clause in my resolver.query in my client class

Steven Parker
Steven Parker
231,127 Points

OK, see if it works for you here. If you don't get many/any responses in a few days you might consider moving it then.

Seth Kroger
Seth Kroger
56,413 Points

This is definitely an Android question since it deals with ContentResolver, not a database question. I would suggest checking out the Content Provider workshop here and Content Provider Basics on the Android Developer site if you haven't yet.