Browse Source

代码整理

huyuguo 5 years ago
parent
commit
a1dbf269a8

+ 0 - 15
app/src/main/java/com/electric/chargingpile/activity/MainMapActivity.java

749
        registerReceiver(networkChangeReceiver, intentFilter);
749
        registerReceiver(networkChangeReceiver, intentFilter);
750
750
751
        EventBusUtil.register(this);
751
        EventBusUtil.register(this);
752
//        Map<String ,String> map = new HashMap<>();
753
//        map.put("user_id","123456");
754
//        map.put("password","juijncui");
755
//        map.put("user_name","miojniuniu");
756
//        String s = Md5Util.getSignTwo(map);
757
//        Log.e("1111",s);
758
//        getGaode(113.19084294353,23.474732420387);
759
//        getAssetsCacheFile(getApplicationContext(), "zhan_list.db");
760
//        Log.e("i***=", MainApplication.count + "");
761
762
//        Log.e("type===", MainApplication.type);
763
//        Log.e("url===", MainApplication.h5_url);
764
        if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushWeb")) {
752
        if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushWeb")) {
765
            Intent intent = new Intent(getApplicationContext(), MyWebViewActivity.class);
753
            Intent intent = new Intent(getApplicationContext(), MyWebViewActivity.class);
766
//            intent.putExtra("tag", "5");
767
            intent.putExtra("url", MainApplication.h5_url);
754
            intent.putExtra("url", MainApplication.h5_url);
768
            startActivity(intent);
755
            startActivity(intent);
769
            MainApplication.h5_url = "";
756
            MainApplication.h5_url = "";
4453
        File databasePath = getDatabasePath("zhan_list");
4440
        File databasePath = getDatabasePath("zhan_list");
4454
        databasePath.getParentFile().mkdirs();
4441
        databasePath.getParentFile().mkdirs();
4455
        databasePath.createNewFile();
4442
        databasePath.createNewFile();
4456
//        Log.e("path===", databasePath.getPath());
4457
//        Log.e("path===", databasePath.getAbsolutePath());
4458
        InputStream inputStream = getAssets().open("zhan_list.db");
4443
        InputStream inputStream = getAssets().open("zhan_list.db");
4459
        FileOutputStream fileOutputStream = new FileOutputStream(databasePath);
4444
        FileOutputStream fileOutputStream = new FileOutputStream(databasePath);
4460
4445

+ 6 - 17
app/src/main/java/com/electric/chargingpile/util/ZhanDBHelper.java

29
    private static String DB_PATH = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
29
    private static String DB_PATH = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
30
    //	private static String DB_PATH = "/data/user/0/com.electric.chargingpile/cache/";
30
    //	private static String DB_PATH = "/data/user/0/com.electric.chargingpile/cache/";
31
    /*
31
    /*
32
     * //�����������ݿ��ļ������SD���Ļ� private static String DB_PATH =
33
     * android.os.Environment.getExternalStorageDirectory().getAbsolutePath() +
32
     * android.os.Environment.getExternalStorageDirectory().getAbsolutePath() +
34
     * "/arthurcn/drivertest/packfiles/";
33
     * "/arthurcn/drivertest/packfiles/";
35
     */
34
     */
41
    private final Context myContext;
40
    private final Context myContext;
42
41
43
    /**
42
    /**
44
     * ������ݿ��ļ��ϴ�ʹ��FileSplit�ָ�ΪС��1M��С�ļ� �����зָ�Ϊ hello.db.101 hello.db.102
45
     * hello.db.103
46
     */
43
     */
47
    // ��һ���ļ�����׺
48
    private static final int ASSETS_SUFFIX_BEGIN = 101;
44
    private static final int ASSETS_SUFFIX_BEGIN = 101;
49
    // ���һ���ļ�����׺
50
    private static final int ASSETS_SUFFIX_END = 103;
45
    private static final int ASSETS_SUFFIX_END = 103;
51
46
52
    /**
47
    /**
53
     * ��SQLiteOpenHelper�����൱�У������иù��캯��
54
     *
48
     *
55
     * @param context ��������
56
     * @param name    ���ݿ�����
57
     * @param factory һ�㶼��null
58
     * @param version ��ǰ���ݿ�İ汾��ֵ���������������ǵ�����״̬
49
     * @param context
50
     * @param name
51
     * @param factory
52
     * @param version
59
     */
53
     */
60
    public ZhanDBHelper(Context context, String name, CursorFactory factory,
61
                        int version) {
62
        // ����ͨ��super���ø��൱�еĹ��캯��
54
    public ZhanDBHelper(Context context, String name, CursorFactory factory, int version) {
63
        super(context, name, null, version);
55
        super(context, name, null, version);
64
        this.myContext = context;
56
        this.myContext = context;
65
    }
57
    }
79
    public void createDataBase() throws IOException {
71
    public void createDataBase() throws IOException {
80
        boolean dbExist = checkDataBase();
72
        boolean dbExist = checkDataBase();
81
        if (dbExist) {
73
        if (dbExist) {
82
            // ���ݿ��Ѵ��ڣ�do nothing.
74
            // do nothing
83
        } else {
75
        } else {
84
            // �������ݿ�
85
            try {
76
            try {
86
                File dir = new File(DB_PATH);
77
                File dir = new File(DB_PATH);
87
                if (!dir.exists()) {
78
                if (!dir.exists()) {
92
                    dbf.delete();
83
                    dbf.delete();
93
                }
84
                }
94
                SQLiteDatabase.openOrCreateDatabase(dbf, null);
85
                SQLiteDatabase.openOrCreateDatabase(dbf, null);
95
                // ����asseets�е�db�ļ���DB_PATH��
96
                copyDataBase();
86
                copyDataBase();
97
            } catch (IOException e) {
87
            } catch (IOException e) {
98
                throw new Error("���ݿⴴ��ʧ��");
88
                throw new Error("���ݿⴴ��ʧ��");
100
        }
90
        }
101
    }
91
    }
102
92
103
    // ������ݿ��Ƿ���Ч
104
    private boolean checkDataBase() {
93
    private boolean checkDataBase() {
105
        SQLiteDatabase checkDB = null;
94
        SQLiteDatabase checkDB = null;
106
        String myPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
95
        String myPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";