Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.ComponentName; import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; public class Main { private static final String DEFAULT_VIEWER_PREFIX = "default_viewer_"; public static ComponentName getDefaultViewerComponentName(Context context, String fullPath, String mimeType) { String viewer = PreferenceManager.getDefaultSharedPreferences(context) .getString(DEFAULT_VIEWER_PREFIX + fullPath, null); if (viewer == null) { viewer = PreferenceManager.getDefaultSharedPreferences(context) .getString(DEFAULT_VIEWER_PREFIX + mimeType, null); } if (viewer != null) { String[] comps = viewer.split("\t"); if (comps.length == 2) { return new ComponentName(comps[0], comps[1]); } throw new IllegalArgumentException("Unable to decode " + TextUtils.join(" ", comps)); } return null; } }