2013-11-14 64 views
0

我想爲我的數據庫填充一個android應用程序,但我不知道我是否做得很好。所以我想問一下這裏一點幫助在android中填充數據庫的更有效的方法

這裏是我的DB

代碼
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); 

} 

,這裏是我的方法的onCreate中的Java文件,我想表明從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();   
} 
的resuld

所以我只想知道其他方法來填充數據庫或(createData)或這種方法是好的。謝謝你在前進

回答

相關問題