Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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 void setDefaultViewer(Context context, String mimeType, String activityPackage,
            String activityName) {
        if (TextUtils.isEmpty(mimeType)) {
            throw new IllegalArgumentException("Default viewer type can't be empty");
        }

        PreferenceManager.getDefaultSharedPreferences(context).edit()
                .putString(DEFAULT_VIEWER_PREFIX + mimeType, activityPackage + "\t" + activityName).apply();
    }
}