0
我正在處理一個應用程序,其中有2個多行EditText,我需要將它們存儲到數據庫中。我只知道如何存儲單行EditText。如何將Multiline EditText存儲到SQLiteDatabase中? [ANDROID]
這裏是我的代碼插入到數據庫:
btnSave = (Button) findViewById(R.id.btnSave);
btnSave.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//startActivityForResult(new Intent(Intent.ACTION_PICK),PICK_CONTACT);
likeDB.open();
long likes_id;
Spinner nameSpinner = (Spinner) findViewById(R.id.nameSpinner);
String NameValue = nameSpinner.getSelectedItem().toString();
EditText txtLikes = (EditText) findViewById(R.id.txtLikes);
String LikesValue = txtLikes.getText().toString();
likes_id = likeDB.insertLikes(NameValue, LikesValue);
likeDB.close();
dislikeDB.open();
long dislikes_id;
Spinner names = (Spinner) findViewById(R.id.nameSpinner);
String NamesValue = names.getSelectedItem().toString();
EditText txtDislikes = (EditText) findViewById(R.id.txtDislikes);
String DislikesValue = txtDislikes.getText().toString();
dislikes_id = dislikeDB.insertDislikes(NamesValue, DislikesValue);
Toast.makeText(getBaseContext(),
"Your information is saved successfully!", Toast.LENGTH_SHORT).show();
dislikeDB.close();
}
});
這,我已經聲明瞭LikeDBAdapter和DislikesDBAdapter在上面的onCreate()方法的代碼:
LikesDBAdapter likeDB = new LikesDBAdapter(this);
DislikesDBAdapter dislikeDB = new DislikesDBAdapter(this);
我需要幫助這個。任何幫助將不勝感激。謝謝!
=)
你能告訴我們你的數據庫的樣子?既然你可以存儲一行,那麼你不會再難以存儲第二行。您可以在表格中添加另一個字段以存儲第二行。 –