我正在开发一个应用程序,其中有 2 个 Multiline EditText,我需要将它们存储到数据库中。我只知道如何存储单行 EditText。
这是我插入数据库的代码:
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();
}
});
这是我在 onCreate() 方法上方声明 LikeDBAdapter 和 DislikesDBAdapter 的代码:
LikesDBAdapter likeDB = new LikesDBAdapter(this);
DislikesDBAdapter dislikeDB = new DislikesDBAdapter(this);
我需要这方面的帮助。任何帮助将不胜感激。谢谢!
=)