国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站建設(shè)論文的前言南京seo排名優(yōu)化

網(wǎng)站建設(shè)論文的前言,南京seo排名優(yōu)化,溫州網(wǎng)站建設(shè)專家,wordpress改造論壇依賴 "androidx.room:room-runtime:2.2.6" "androidx.room:room-compiler:2.2.6" 1.實(shí)體類 實(shí)體類需要保存到數(shù)據(jù)庫的新類用Entity注解表示 tableName是數(shù)據(jù)庫中表的名字,my_advert可以根據(jù)自己需要自定義 PrimaryKey,NonNull主鍵…

依賴

"androidx.room:room-runtime:2.2.6"
"androidx.room:room-compiler:2.2.6"

1.實(shí)體類

實(shí)體類需要保存到數(shù)據(jù)庫的新類用@Entity注解表示
tableName是數(shù)據(jù)庫中表的名字,my_advert可以根據(jù)自己需要自定義
?@PrimaryKey,@NonNull主鍵不能為空


@Entity(tableName = "my_advert") public class MyAdvertBean { /** * 素材id, */ @PrimaryKey @NonNull private String moduleId; /** * 廣告日期,一天一重置 */ private String date; /** * 存儲(chǔ)廣告的 */ private String message; @NonNull public String getModuleId() { return moduleId; } public void setModuleId(@NonNull String moduleId) { this.moduleId = moduleId; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }

2.定義數(shù)據(jù)庫增刪改查

關(guān)鍵注解:@Insert增,@Delete刪,@Update改,@Query查

@Dao
public interface MyAdvertDao {/*** 根據(jù)id查詢保存的廣告* @param moduleId 模塊id* @return*/@Query("select * from my_advert where moduleId = :moduleId LIMIT 1")MyAdvertBean queryMyAdvert(String moduleId);/*** 刪除本地廣告* @param myAdvertBean 廣告*/@Deletevoid deleteAdvert(MyAdvertBean myAdvertBean);/*** 廣告保存本地* @param myAdvertBean 廣告*/@Insert(onConflict = OnConflictStrategy.REPLACE)void insertAdvert(MyAdvertBean myAdvertBean);/*** 更新本地廣告信息* @param myAdvertBean 廣告*/@Updatevoid updateAdvert(MyAdvertBean myAdvertBean);
}

3.數(shù)據(jù)庫升級(jí)等操作Base,繼承RoomDataBase

@Database注解用來標(biāo)注數(shù)據(jù)庫中有哪幾張表,自己新加的MyAdvertBean加入里面 ,然后version增加版本1,從5到6

@TypeConverters是用來list數(shù)據(jù)存儲(chǔ)

數(shù)據(jù)庫版本原來是5,我需要插入新的表,執(zhí)行MIGRATION_5_6,版本需要加1

@Database(entities = {UserEntity.class, BrowseRecordEntity.class, MyAdvertBean.class}, version = 6)
@TypeConverters({BaseObjDataConvert.class})
public abstract class UserDatabase extends BaseDatabase {public abstract UserDao getUserDao();public abstract BrowseRecordDao getRecordDao();public abstract MyAdvertDao getMyAdvertDao();private static UserDatabase instance;public static UserDatabase getInstance() {if (instance == null) {synchronized (UserDatabase.class) {if (instance == null) {instance = Room.databaseBuilder(Utils.getApp(), UserDatabase.class, "shandian").addMigrations(MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,MIGRATION_5_6).allowMainThreadQueries().build();}}}return instance;}static final Migration MIGRATION_2_3 = new Migration(2, 3) {@Overridepublic void migrate(@NonNull SupportSQLiteDatabase database) {database.execSQL("alter table user add column sex TEXT");database.execSQL("alter table user add column birthday TEXT");database.execSQL("alter table user add column signature TEXT");database.execSQL("alter table user add column totalScore Text");database.execSQL("alter table user add column score Text");}};static final Migration MIGRATION_3_4 = new Migration(3, 4) {@Overridepublic void migrate(@NonNull SupportSQLiteDatabase database) {database.execSQL("CREATE TABLE IF NOT EXISTS browse_record (type TEXT, articleId TEXT PRIMARY KEY NOT NULL,opentype TEXT," +"param TEXT,title TEXT,publish_at_time INTEGER NOT NULL DEFAULT 0)");}};static final Migration MIGRATION_4_5 = new Migration(4, 5) {@Overridepublic void migrate(@NonNull SupportSQLiteDatabase database) {database.execSQL("alter table browse_record add column browse_time INTEGER NOT NULL DEFAULT 0");}};/*** 廣告數(shù)據(jù)庫表*/static final Migration MIGRATION_5_6 = new Migration(5, 6) {@Overridepublic void migrate(@NonNull SupportSQLiteDatabase database) {database.execSQL("CREATE TABLE IF NOT EXISTS my_advert (date TEXT, moduleId TEXT PRIMARY KEY NOT NULL,message TEXT)");}};}

public class BaseObjDataConvert{@TypeConverterpublic NavconfigBean revert(String data) {try {return GsonUtils.fromJson(data, NavconfigBean.class);} catch (Exception e) {e.printStackTrace();}return null;}@TypeConverterpublic String convert(NavconfigBean data) {return GsonUtils.toJson(data);}
}
http://aloenet.com.cn/news/28299.html

相關(guān)文章:

  • 深業(yè)資本有限公司網(wǎng)站建設(shè)成都高端品牌網(wǎng)站建設(shè)
  • 江蘇靖江蘇源建設(shè)有限公司招標(biāo)網(wǎng)站搜盤 資源網(wǎng)
  • 網(wǎng)站建設(shè)優(yōu)化兼職成都seo工程師
  • 網(wǎng)站seo診斷評(píng)分63淘寶指數(shù)查詢
  • 上海閔行網(wǎng)站制作公司全網(wǎng)推廣方案
  • 做網(wǎng)站銷售一個(gè)星期的計(jì)劃市場營銷案例
  • 政府網(wǎng)站免費(fèi)模板產(chǎn)品營銷方案策劃
  • 三端互通傳奇手游找服網(wǎng)站百度一下首頁手機(jī)版
  • 商城類網(wǎng)站建設(shè)需要多少錢標(biāo)題優(yōu)化怎樣選關(guān)鍵詞
  • 人力資源公司網(wǎng)站模板網(wǎng)頁設(shè)計(jì)制作網(wǎng)站模板
  • 巫山網(wǎng)站開發(fā)太原seo哪家好
  • 淘寶怎么做網(wǎng)站網(wǎng)絡(luò)優(yōu)化大師app
  • 專業(yè)網(wǎng)站設(shè)計(jì)制作費(fèi)用下載百度到桌面
  • 網(wǎng)站欄目劃分的原則瀏覽器如何推廣自己網(wǎng)站
  • 網(wǎng)站制作的頁面比例上海單個(gè)關(guān)鍵詞優(yōu)化
  • 北京網(wǎng)站建設(shè)哪家好百度官網(wǎng)認(rèn)證免費(fèi)
  • 煙臺(tái)seo關(guān)鍵詞排名優(yōu)化英文
  • 網(wǎng)站開發(fā)數(shù)據(jù)庫分析模板谷歌官網(wǎng)入口
  • 常州武進(jìn)區(qū)建設(shè)局網(wǎng)站吉林網(wǎng)站推廣公司
  • 寫作網(wǎng)站一稿多投的后果海外廣告投放公司
  • 佛山企業(yè)網(wǎng)站制作公司線上平臺(tái)怎么推廣
  • 網(wǎng)站搜索框用ps怎么做長春最新發(fā)布信息
  • 營銷型網(wǎng)站建設(shè)好不好免費(fèi)營銷軟件網(wǎng)站
  • 嘟嘟嘟在線觀看播放免費(fèi)寧波seo外包推廣平臺(tái)
  • 陜西省建設(shè)廳網(wǎng)站月報(bào)免費(fèi)域名的網(wǎng)站
  • 晉江論壇匿名區(qū)青島seo排名收費(fèi)
  • 微信小程序網(wǎng)站開發(fā)教程旅游seo整站優(yōu)化
  • 蘇州專業(yè)網(wǎng)站建設(shè)開發(fā)網(wǎng)站seo快速排名優(yōu)化的軟件
  • 一個(gè)內(nèi)部網(wǎng)站如何做外網(wǎng)映射百度的推廣廣告
  • 南陽做網(wǎng)站多少錢seo優(yōu)化培訓(xùn)班