Code example for Context

Methods: getApplicationContextgetPackageName

0
     * 
     * @param context The context that should be used for getting/creating the singleton instance. 
     * @return The singleton instance for the context's package. 
     */ 
    public static synchronized DbSSLSessionCache getInstanceForPackage(Context context) {
        String packageName = context.getPackageName();
        if (sInstances.containsKey(packageName)) {
            return sInstances.get(packageName);
        } 
        DbSSLSessionCache cache = new DbSSLSessionCache(context);
        sInstances.put(packageName, cache);
        return cache;
    } 
     
    /** 
     * Create a SslSessionCache instance, using the specified context to  
     * initialize the database. 
     *  
     * This constructor will use the default database - created for the application 
     * context. 
     *  
     * @param activityContext 
     */ 
    private DbSSLSessionCache(Context activityContext) {
        Context appContext = activityContext.getApplicationContext();
        mDatabaseHelper = new DatabaseHelper(appContext);
    } 
     
    /** 
     * Create a SslSessionCache that uses a specific database.