public class ICDatabaseHelper extends SQLiteOpenHelper {
+
+ private final static int VERSION_1 = 1;
+ private final static int VERSION_2 = 2;
public static final String DB_NAME = "fzd_db";
- private static final int DEFAULT_VERSION = 1;
+ private static final int DEFAULT_VERSION = VERSION_2;//2021-9-6
public ICDatabaseHelper(@Nullable Context context) {
" date)";
ICLogger.d(createShoot);
db.execSQL(createShoot);
+
+ createForbiddenTable(db);
}
//闹钟数据库
public static final String shoot_create_time = "create_time";
public static final String shoot_update_time = "update_time";
+ //上课禁用时间段表
+ public static final String tb_forbidden_time = "forbidden_time";
+ public static final String forbidden_id = "_id";
+ //开始时间
+ public static final String forbidden_start = "start";
+ //结束时间
+ public static final String forbidden_end = "end";
+ //开关状态
+ public static final String forbidden_status = "status";
+ //创建时间和更新时间
+ public static final String forbidden_create_time = "create_time";
+ public static final String forbidden_update_time = "update_time";
+
+
+ private void createForbiddenTable(SQLiteDatabase db) {
+ String sql = "create table " +
+ tb_forbidden_time +
+ " (" +
+ forbidden_id +
+ " integer primary key autoincrement, " +
+ forbidden_start +
+ " text, " +
+ forbidden_end +
+ " text, " +
+ forbidden_status +
+ " text, " +
+ forbidden_create_time +
+ " date, " +
+ forbidden_update_time +
+ " date)";
+ ICLogger.d("sql ==> " + sql);
+ db.execSQL(sql);
+ }
+
+
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//升级数据库
-
+ if (oldVersion == VERSION_1 && newVersion == VERSION_2) {
+ createForbiddenTable(db);
+ }
}
}
--- /dev/null
+package com.enqualcomm.support.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * 上课禁用时间段的内容提供者
+ */
+public class ICForbiddenProvider extends ContentProvider {
+
+ @Override
+ public boolean onCreate() {
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri, @Nullable String[] projection,
+ @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
+ return 0;
+ }
+}
}
public void saveSilent(ArrayList<Silent> sList) {
- Cursor cursor = this.cr.query(ICContentProvider.SILENT_URI, (String[]) null, (String) null, (String[]) null, (String) null);
+ Cursor cursor = this.cr.query(ICContentProvider.SILENT_URI,
+ (String[]) null, (String) null, (String[]) null, (String) null);
String current_sys_status;
if (cursor != null) {
//获取silent免打扰状态 ON/OFF
}
Silent silent = new Silent(start, end, week_sb.toString(), status);
slist.add(silent);
- ICLogger.i("set silence " + start + " " + end + " " + week_sb.toString() + " " + status);
+ ICLogger.i("set silence " +
+ start + " " + end + " "
+ + week_sb.toString() + " " + status);
} else {
ICLogger.i("免打扰时间格式错误,skip");
}