Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
    /**
     * Check is classes.dex file has modified
     * 
     * @author : sWX293372
     * @version: 1.0
     * @return boolean if the classes.dex is modified then return true, else
     *         return true
     * @createTime : 2016-5-9
     */
    public static boolean checkCRC(Context context, long crc) {
        boolean isModified = true;
        try {
            ZipFile zipFile = new ZipFile(context.getPackageCodePath());
            ZipEntry entry = zipFile.getEntry("classes.dex");
            if (crc == entry.getCrc()) {
                isModified = false;
            }
        } catch (IOException e) {
            isModified = true;
            e.printStackTrace();
        }
        return isModified;
    }
}