1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.dialer.preferredsim.impl; 18 19 import android.content.Context; 20 import android.database.sqlite.SQLiteDatabase; 21 import android.database.sqlite.SQLiteOpenHelper; 22 import com.android.dialer.common.LogUtil; 23 import com.android.dialer.preferredsim.PreferredSimFallbackContract.PreferredSim; 24 25 /** Database helper class for preferred SIM. */ 26 public class PreferredSimDatabaseHelper extends SQLiteOpenHelper { 27 28 static final String TABLE = "preferred_sim"; 29 30 private static final String CREATE_TABLE_SQL = 31 "create table if not exists " 32 + TABLE 33 + " (" 34 + (PreferredSim.DATA_ID + " integer primary key, ") 35 + (PreferredSim.PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME + " text, ") 36 + (PreferredSim.PREFERRED_PHONE_ACCOUNT_ID + " text") 37 + ");"; 38 PreferredSimDatabaseHelper(Context appContext)39 PreferredSimDatabaseHelper(Context appContext) { 40 super(appContext, "preferred_sim.db", null, 1); 41 } 42 43 @Override onCreate(SQLiteDatabase db)44 public void onCreate(SQLiteDatabase db) { 45 LogUtil.enterBlock("PreferredSimDatabaseHelper.onCreate"); 46 long startTime = System.currentTimeMillis(); 47 db.execSQL(CREATE_TABLE_SQL); 48 LogUtil.i( 49 "PreferredSimDatabaseHelper.onCreate", 50 "took: %dms", 51 System.currentTimeMillis() - startTime); 52 } 53 54 @Override onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)55 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {} 56 } 57