Using ORMLite with Fragments

Can I use ORMLite to manage your local database while using Android Fragments?

Sample code or links to sample code showing how to create something like the ORMLiteFragmentActivity class would be cool. Or I think a simple no can be an acceptable answer. :)

+4
source share
2 answers

Yes, it is quite possible. See instructions here . Basically, all you do is create a new class, as you expected. You can replace Fragment with any other type that you want to expand. For example, I also have an OrmLiteListFragment that extends ListFragment

 public class OrmLiteFragment extends Fragment { private DatabaseHelper databaseHelper = null; protected DatabaseHelper getHelper() { if (databaseHelper == null) { databaseHelper = OpenHelperManager.getHelper(getActivity(), DatabaseHelper.class); } return databaseHelper; } @Override public void onDestroy() { super.onDestroy(); if (databaseHelper != null) { OpenHelperManager.releaseHelper(); databaseHelper = null; } } } 
+15
source

you can control ormlite db only after onstart () is called

sorry i'm new at stackoverflow http://my.oschina.net/zengliubao/blog/528132

-1
source

Source: https://habr.com/ru/post/1441334/


All Articles