Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df17ec4b authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Update ContentProvider documentation" into main

parents adf8892e 390d51e3
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1483,6 +1483,12 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
        // proper SQL syntax for us.
        SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();

        // Guard against SQL injection attacks
        qBuilder.setStrict(true);
        qBuilder.setProjectionMap(MAP_OF_QUERYABLE_COLUMNS);
        qBuilder.setStrictColumns(true);
        qBuilder.setStrictGrammar(true);

        // Set the table we're querying.
        qBuilder.setTables(DATABASE_TABLE_NAME);

@@ -1546,6 +1552,12 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
        // proper SQL syntax for us.
        SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();

        // Guard against SQL injection attacks
        qBuilder.setStrict(true);
        qBuilder.setProjectionMap(MAP_OF_QUERYABLE_COLUMNS);
        qBuilder.setStrictColumns(true);
        qBuilder.setStrictGrammar(true);

        // Set the table we're querying.
        qBuilder.setTables(DATABASE_TABLE_NAME);

+9 −0
Original line number Diff line number Diff line
@@ -48,6 +48,15 @@ import java.util.regex.Pattern;
/**
 * This is a convenience class that helps build SQL queries to be sent to
 * {@link SQLiteDatabase} objects.
 * <p>
 * This class is often used to compose a SQL query from client-supplied fragments.  Best practice
 * to protect against invalid or illegal SQL is to set the following:
 * <ul>
 * <li>{@link #setStrict} true.
 * <li>{@link #setProjectionMap} with the list of queryable columns.
 * <li>{@link #setStrictColumns} true.
 * <li>{@link #setStrictGrammar} true.
 * </ul>
 */
public class SQLiteQueryBuilder {
    private static final String TAG = "SQLiteQueryBuilder";