Code example for SparseArray

0
public class UriMapper<T> { 
 
    // This hold 10 character (i.e. content://) 
    private static final int CONTENT_LENGHT = 10;
 
    private SparseArray<T> uriToUrl = new SparseArray<T>();
 
    private UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
 
    private int code = 0;
 
    /* 
     * Ability to hook into the response object before it is returned 
     */ 
    private Transformer<T> transformer = null;
 
    public void map(Uri uri, T url) {
        matcher.addURI(uri.getAuthority(), sanifyPath(uri), code);
        uriToUrl.append(code, url);
        code += 1;
    }