我是android编程的新手!我有一个MainActivity,其中onCreate看起来像这样:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DBHandler db = new DBHandler(this);
db.onUpgrade(db.getWritableDatabase(), 1, 2); // I have to figure out how to make the app create the database on install and not on app launch
//Here all tables are filled up. It's hardcoded as the data is not intented to be changed by the user
String ATABLENAME = "aTableName";
db.addKeyPoint(new AKeyPoint(1, "sometext", 167, "areference"), ATABLENAME);
db.addKeyPoint(new AKeyPoint(2, "someothertext", 0, "anotherreference"), ATABLENAME);
}
Run Code Online (Sandbox Code Playgroud)
我还有一个InitActivity,只需按一下按钮即可启动.在这里我有一个实现LoaderManager.LoaderCallbacks的ListFragment:
public static class KeyFragment …Run Code Online (Sandbox Code Playgroud) sqlite android cursor nullpointerexception android-listfragment