Java Code Examples for org.litepal.LitePal#getDatabase()
The following examples show how to use
org.litepal.LitePal#getDatabase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyApplication.java From PoetryWeather with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); LitePal.initialize(context); LitePal.getDatabase(); //初始化随机获取诗词 JinrishiciClient.getInstance().init(this); QMUISwipeBackActivityManager.init(this); //注册Mob MobSDK.init(this); //注册和风天气 HeConfig.init("HE1808181021011344","c6a58c3230694b64b78facdebd7720fb"); HeConfig.switchToFreeServerNode(); QMUISwipeBackActivityManager.init(this); }
Example 2
Source File: AlbumSongFragment.java From Yuan-SxMusic with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getBundle(); EventBus.getDefault().register(this); View view = null; if (mType == ALBUM_SONG) { view = inflater.inflate(R.layout.fragment_album_recycler, container, false); mRecycle = view.findViewById(R.id.normalView); LitePal.getDatabase(); } else { view = inflater.inflate(R.layout.fragment_album_song, container, false); mScrollView = view.findViewById(R.id.scrollView); mDescTv = view.findViewById(R.id.tv_desc); mNameTv = view.findViewById(R.id.tv_album_name); mLanguageTv = view.findViewById(R.id.tv_language); mCompany = view.findViewById(R.id.tv_company); mPublicTimeTv = view.findViewById(R.id.tv_public_time); mTypeTv = view.findViewById(R.id.tv_album_type); } mLoading = view.findViewById(R.id.avi); mLoadingTv = view.findViewById(R.id.tv_loading); mNetworkErrorIv = view.findViewById(R.id.iv_network_error); return view; }
Example 3
Source File: App.java From WanAndroid with Apache License 2.0 | 4 votes |
private void initLitepal() { LitePal.getDatabase(); }
Example 4
Source File: MainActivity.java From Yuan-SxMusic with Apache License 2.0 | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.O) @Override protected void initView() { EventBus.getDefault().register(this); LitePal.getDatabase(); //设置属性动画 mCircleAnimator = ObjectAnimator.ofFloat(mCoverIv, "rotation", 0.0f, 360.0f); mCircleAnimator.setDuration(30000); mCircleAnimator.setInterpolator(new LinearInterpolator()); mCircleAnimator.setRepeatCount(-1); mCircleAnimator.setRepeatMode(ValueAnimator.RESTART); mSong = FileUtil.getSong(); if (mSong.getSongName() != null) { Log.d(TAG, "initView: " + mSong.toString()); mLinear.setVisibility(View.VISIBLE); mSongNameTv.setText(mSong.getSongName()); mSingerTv.setText(mSong.getSinger()); mSeekBar.setMax((int) mSong.getDuration()); mSeekBar.setProgress((int) mSong.getCurrentTime()); if (mSong.getImgUrl() == null) { CommonUtil.setSingerImg(MainActivity.this, mSong.getSinger(), mCoverIv); } else { Glide.with(this) .load(mSong.getImgUrl()) .apply(RequestOptions.placeholderOf(R.drawable.welcome)) .apply(RequestOptions.errorOf(R.drawable.welcome)) .into(mCoverIv); } } else { mSongNameTv.setText(getString(R.string.app_name)); mSingerTv.setText(getString(R.string.welcome_start)); mCoverIv.setImageResource(R.drawable.jay); } //如果播放服务还存活 if(ServiceUtil.isServiceRunning(this,PlayerService.class.getName())){ mPlayerBtn.setSelected(true); mCircleAnimator.start(); isExistService = true; } //处理服务 initService(); addMainFragment(); }
Example 5
Source File: ChooseAreaActivity.java From BS-Weather with Apache License 2.0 | 4 votes |
@Override public void initData() { LitePal.getDatabase(); }
Example 6
Source File: ColumnTest.java From LitePal with Apache License 2.0 | 4 votes |
@Before public void setUp() { LitePal.getDatabase(); }
Example 7
Source File: MultiDatabaseTest.java From LitePal with Apache License 2.0 | 4 votes |
@Test public void testMultiDatabase() { LitePal.deleteDatabase("db2"); SQLiteDatabase db = LitePal.getDatabase(); assertTrue(DBUtility.isTableExists("Album", db)); assertTrue(DBUtility.isTableExists("Song", db)); assertTrue(DBUtility.isTableExists("Singer", db)); assertTrue(DBUtility.isTableExists("Classroom", db)); assertTrue(DBUtility.isTableExists("Teacher", db)); assertTrue(DBUtility.isTableExists("IdCard", db)); assertTrue(DBUtility.isTableExists("Student", db)); assertTrue(DBUtility.isTableExists("Cellphone", db)); assertTrue(DBUtility.isTableExists("Computer", db)); assertTrue(DBUtility.isTableExists("Book", db)); assertTrue(DBUtility.isTableExists("Product", db)); assertTrue(DBUtility.isTableExists("Headset", db)); assertTrue(DBUtility.isTableExists("WeChatMessage", db)); assertTrue(DBUtility.isTableExists("WeiboMessage", db)); LitePalDB litePalDB = new LitePalDB("db2", 1); litePalDB.addClassName(Classroom.class.getName()); litePalDB.addClassName(Product.class.getName()); litePalDB.setExternalStorage(true); LitePal.use(litePalDB); db = LitePal.getDatabase(); assertFalse(DBUtility.isTableExists("Album", db)); assertFalse(DBUtility.isTableExists("Song", db)); assertFalse(DBUtility.isTableExists("Singer", db)); assertTrue(DBUtility.isTableExists("Classroom", db)); assertFalse(DBUtility.isTableExists("Teacher", db)); assertFalse(DBUtility.isTableExists("IdCard", db)); assertFalse(DBUtility.isTableExists("Student", db)); assertFalse(DBUtility.isTableExists("Cellphone", db)); assertFalse(DBUtility.isTableExists("Computer", db)); assertFalse(DBUtility.isTableExists("Book", db)); assertTrue(DBUtility.isTableExists("Product", db)); assertFalse(DBUtility.isTableExists("Headset", db)); assertFalse(DBUtility.isTableExists("WeChatMessage", db)); assertFalse(DBUtility.isTableExists("WeiboMessage", db)); litePalDB = new LitePalDB("db2", 2); litePalDB.addClassName(Computer.class.getName()); litePalDB.addClassName(Product.class.getName()); litePalDB.addClassName(Headset.class.getName()); litePalDB.setExternalStorage(true); LitePal.use(litePalDB); db = LitePal.getDatabase(); assertFalse(DBUtility.isTableExists("Album", db)); assertFalse(DBUtility.isTableExists("Song", db)); assertFalse(DBUtility.isTableExists("Singer", db)); assertFalse(DBUtility.isTableExists("Classroom", db)); assertFalse(DBUtility.isTableExists("Teacher", db)); assertFalse(DBUtility.isTableExists("IdCard", db)); assertFalse(DBUtility.isTableExists("Student", db)); assertFalse(DBUtility.isTableExists("Cellphone", db)); assertTrue(DBUtility.isTableExists("Computer", db)); assertFalse(DBUtility.isTableExists("Book", db)); assertTrue(DBUtility.isTableExists("Product", db)); assertTrue(DBUtility.isTableExists("Headset", db)); assertFalse(DBUtility.isTableExists("WeChatMessage", db)); assertFalse(DBUtility.isTableExists("WeiboMessage", db)); LitePal.useDefault(); db = LitePal.getDatabase(); assertTrue(DBUtility.isTableExists("Album", db)); assertTrue(DBUtility.isTableExists("Song", db)); assertTrue(DBUtility.isTableExists("Singer", db)); assertTrue(DBUtility.isTableExists("Classroom", db)); assertTrue(DBUtility.isTableExists("Teacher", db)); assertTrue(DBUtility.isTableExists("IdCard", db)); assertTrue(DBUtility.isTableExists("Student", db)); assertTrue(DBUtility.isTableExists("Cellphone", db)); assertTrue(DBUtility.isTableExists("Computer", db)); assertTrue(DBUtility.isTableExists("Book", db)); assertTrue(DBUtility.isTableExists("Product", db)); assertTrue(DBUtility.isTableExists("Headset", db)); assertTrue(DBUtility.isTableExists("WeChatMessage", db)); assertTrue(DBUtility.isTableExists("WeiboMessage", db)); }