List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:com.alchemiasoft.common.content.BookDBOpenHelper.java
public BookDBOpenHelper(Context context) { super(context, BookDB.NAME, null, BookDB.VERSION); mContext = context.getApplicationContext(); }
From source file:org.geometerplus.zlibrary.ui.android.network.SQLiteCookieDatabase.java
SQLiteCookieDatabase(Context context) { myDatabase = context.getApplicationContext().openOrCreateDatabase("cookie.db", Context.MODE_PRIVATE, null); myDatabase.execSQL("CREATE TABLE IF NOT EXISTS Cookie(" + "cookie_id INTEGER PRIMARY KEY," + "host TEXT NOT NULL," + "path TEXT," + "name TEXT NOT NULL," + "value TEXT NOT NULL," + "date_of_expiration INTEGER," + "secure INTEGER," + "CONSTRAINT Cookie_Unique UNIQUE(host,path,name))"); myDatabase.execSQL("CREATE TABLE IF NOT EXISTS CookiePort(" + "cookie_id INTEGER NOT NULL REFERENCES Cookie(cookie_id)," + "port INTEGER NOT NULL," + "CONSTRAINT CookiePort_Unique UNIQUE(cookie_id,port))"); myInsertStatement = myDatabase//from ww w .j a v a2s . c o m .compileStatement("INSERT OR REPLACE INTO Cookie (host,path,name,value,date_of_expiration,secure) " + "VALUES (?,?,?,?,?,?)"); myInsertPortsStatement = myDatabase .compileStatement("INSERT OR IGNORE INTO CookiePort (cookie_id,port) VALUES (?,?)"); myDeletePortsStatement = myDatabase.compileStatement("DELETE FROM CookiePort WHERE cookie_id = ?"); removeObsolete(new Date()); }
From source file:edu.pdx.cecs.orcycle.SegmentData.java
private SegmentData(Context ctx, long segment_id) { Context context = ctx.getApplicationContext(); this.segmentId = segment_id; mDb = new DbAdapter(context); }
From source file:com.jobs.lib_v1.imageloader.core.download.BaseImageDownloader.java
public BaseImageDownloader(Context context) { this.context = context.getApplicationContext(); }
From source file:im.vector.store.LoginStorage.java
public LoginStorage(Context appContext) { mContext = appContext.getApplicationContext(); }
From source file:at.florian_lentsch.expirysync.NotifyChecker.java
/** * (non-Javadoc) The alarm has been triggered -> create a notification, if * there are any expired products (or any that will soon expire) *//*from w w w . java 2 s .c o m*/ @Override public void onReceive(Context context, Intent intent) { Context appContext = context.getApplicationContext(); final SharedPreferences sharedPref = appContext.getSharedPreferences("main", Context.MODE_PRIVATE); int daysBeforeMedium = sharedPref.getInt(SettingsActivity.KEY_DAYS_BEFORE_MEDIUM, 0); DatabaseManager.init(appContext); List<ProductEntry> products = DatabaseManager.getInstance().getAllProductEntries(); List<String> expiringProducts = new ArrayList<String>(); for (ProductEntry productEntry : products) { if ((new DateTime(productEntry.expiration_date)).minusDays(daysBeforeMedium).isBeforeNow()) { expiringProducts.add(productEntry.amount + "x " + productEntry.article.name); } } if (expiringProducts.size() > 0) { this.createExpiryNotification(appContext, expiringProducts); } }
From source file:com.apptentive.android.sdk.Apptentive.java
/** * Returns the number of unread messages in the Message Center. * * @param context The Context from which this method is called. * @return The number of unread messages. *//*from ww w . j a v a 2 s . c o m*/ public static int getUnreadMessageCount(Context context) { try { return MessageManager.getUnreadMessageCount(context); } catch (Exception e) { MetricModule.sendError(context.getApplicationContext(), e, null, null); } return 0; }
From source file:com.facebook.FacebookSdk.java
/** * This function initializes the Facebook SDK, the behavior of Facebook SDK functions are * undetermined if this function is not called. It should be called as early as possible. * @param applicationContext The application context *//*from w w w. jav a 2s.c om*/ public static synchronized void sdkInitialize(Context applicationContext) { if (sdkInitialized == true) { return; } Validate.notNull(applicationContext, "applicationContext"); // Don't throw for these validations here, just log an error. We'll throw when we actually // need them Validate.hasFacebookActivity(applicationContext, false); Validate.hasInternetPermissions(applicationContext, false); FacebookSdk.applicationContext = applicationContext.getApplicationContext(); // Make sure we've loaded default settings if we haven't already. FacebookSdk.loadDefaultsFromMetadata(FacebookSdk.applicationContext); // Load app settings from network so that dialog configs are available Utility.loadAppSettingsAsync(FacebookSdk.applicationContext, applicationId); // Fetch available protocol versions from the apps on the device NativeProtocol.updateAllAvailableProtocolVersionsAsync(); BoltsMeasurementEventListener.getInstance(FacebookSdk.applicationContext); cacheDir = FacebookSdk.applicationContext.getCacheDir(); FutureTask<Void> accessTokenLoadFutureTask = new FutureTask<Void>(new Callable<Void>() { @Override public Void call() throws Exception { AccessTokenManager.getInstance().loadCurrentAccessToken(); ProfileManager.getInstance().loadCurrentProfile(); if (AccessToken.getCurrentAccessToken() != null && Profile.getCurrentProfile() == null) { // Access token and profile went out of sync due to a network or caching // issue, retry Profile.fetchProfileForCurrentAccessToken(); } return null; } }); getExecutor().execute(accessTokenLoadFutureTask); sdkInitialized = true; }
From source file:com.google.fpl.liquidfunpaint.renderer.ParticleRenderer.java
@Override public void init(Context context) { mContext = context.getApplicationContext(); // Read in our specific json file materialFile = FileHelper.loadAsset(mContext.getAssets(), JSON_FILE); }
From source file:eu.faircode.adblocker.IAB.java
public IAB(Delegate delegate, Context context) { this.context = context.getApplicationContext(); this.delegate = delegate; }