public static void setPicture(Context context, Media m, Bitmap p) {
   Log.d(TAG, "Setting new picture for " + m.getTitle());
   try {
     MediaDatabase.getInstance(context)
         .updateMedia(m.getLocation(), MediaDatabase.mediaColumn.MEDIA_PICTURE, p);
   } catch (SQLiteFullException e) {
     Log.d(TAG, "SQLiteFullException while setting picture");
   }
   m.setPictureParsed(true);
 }
  @Override
  public void onCreate() {
    super.onCreate();

    // Are we using advanced debugging - locale?
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String p = pref.getString("set_locale", "");
    if (p != null && !p.equals("")) {
      Locale locale;
      // workaround due to region code
      if (p.equals("zh-TW")) {
        locale = Locale.TRADITIONAL_CHINESE;
      } else if (p.startsWith("zh")) {
        locale = Locale.CHINA;
      } else if (p.equals("pt-BR")) {
        locale = new Locale("pt", "BR");
      } else if (p.equals("bn-IN") || p.startsWith("bn")) {
        locale = new Locale("bn", "IN");
      } else {
        /**
         * Avoid a crash of java.lang.AssertionError: couldn't initialize LocaleData for locale if
         * the user enters nonsensical region codes.
         */
        if (p.contains("-")) p = p.substring(0, p.indexOf('-'));
        locale = new Locale(p);
      }
      Locale.setDefault(locale);
      Configuration config = new Configuration();
      config.locale = locale;
      getBaseContext()
          .getResources()
          .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    }

    instance = this;

    // Initialize the database soon enough to avoid any race condition and crash
    MediaDatabase.getInstance();
    // Prepare cache folder constants
    //        AudioUtil.prepareCacheFolder(this);
  }
 public static Bitmap getPictureFromCache(Media media) {
   // mPicture is not null only if passed through
   // the ctor which is deprecated by now.
   Bitmap b = media.getPicture();
   if (b == null) {
     BitmapCache cache = BitmapCache.getInstance();
     Bitmap picture = cache.getBitmapFromMemCache(media.getLocation());
     if (picture == null) {
       /* Not in memcache:
        * serving the file from the database and
        * adding it to the memcache for later use.
        */
       Context c = VLCApplication.getAppContext();
       picture = MediaDatabase.getInstance(c).getPicture(c, media.getLocation());
       cache.addBitmapToMemCache(media.getLocation(), picture);
     }
     return picture;
   } else {
     return b;
   }
 }