0

Android アプリ用に DB を作成したいのですが、うまくいっているかどうかわかりません。そこで、ここで少し助けを求めたいと思います

これが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);

} 

ここに、DBからの結果を表示したいJavaファイルのonCreateメソッドがあります

    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();           
}

繰り返しますが、DBまたは(createData)にデータを入力する他の方法を知りたいだけです。または、この方法が良いです。前もって感謝します

4

1 に答える 1