我想为一个 android 应用程序填充我的数据库,但我不知道我是否做得很好。所以我想在这里寻求一点帮助
这是我的数据库代码
public long createData() {
// TODO Auto-generated method stub
String [] arg = new String [] {"Abdullah", "Abdulatif","Abdulaziz","Abdulbaki","Zafir"};
String [] mng = new String [] { "Adhurues; Rob i Zotit", "Adhurues i Zotit Ledhatues","Adhurues i Zotit Fuqiplotë","Adhurues i Zotit të përhershëm","Fitimtar"};
String [] gnr = new String [] {"Mashkull", "Mashkull","Mashkull", "Mashkull", "Mashkull"};
ContentValues cv = new ContentValues();
for (int i = 0; i < arg.length; i++){
cv.put(KEY_EMRI, arg[i]);
cv.put(KEY_KUPTIMI, mng[i]);
cv.put(KEY_GJINIA, gnr[i]);
ourDatabase.insert(DATABASE_TABLE, null, cv);
}
return ourDatabase.insert(DATABASE_TABLE, null, cv);
}
这是我在 java 文件中的 onCreate 方法,我想显示 DB 的结果
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.meshkuj);
search = (Button) findViewById(R.id.bKerko);
etSearch = (EditText) findViewById(R.id.etKerko);
tvName = (TextView) findViewById(R.id.tvEmr);
tvGenre = (TextView) findViewById(R.id.tvGjinia);
tvMeaning = (TextView) findViewById(R.id.tvKuptimi);
emri = (TextView) findViewById(R.id.tvShEmri);
Emertimet info = new Emertimet(this);
info.open();
info.createData();
info.close();
}
所以我只想知道填充数据库或(createData)的任何其他方法,或者这种方法很好。先感谢您