0
我一直在我的sqlite數據庫[9999] [8888]內使用方括號獲取數據,我需要的是沒有[]的簡單數據。數據與方括號裏面的SQLite數據庫DB
public class AddReminders extends Activity implements OnClickListener {
private Button btn_addrecord;
private EditText txtpname;
String[] versionNames= new String[]{"8888"};
String[] versionNames1= new String[]{"9999"};
ProductModel pm;
DatabaseHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.add_reminder);
db = new DatabaseHelper(getApplicationContext());
db.getWritableDatabase();
pm = new ProductModel();
pm.idno = (Arrays.toString(versionNames));
Log.i("reminderidno", "" + pm.idno);
db.addProduct(pm);
db = new DatabaseHelper(getApplicationContext());
db.getWritableDatabase();
pm = new ProductModel();
pm.idno = (Arrays.toString(versionNames1));
Log.i("reminderidno", "" + pm.idno);
db.addProduct(pm);
txtpname = (EditText) findViewById(R.id.myEditText);
btn_addrecord = (Button) findViewById(R.id.button1);
btn_addrecord.setOnClickListener(this);
}
@Override
public void onClick(View v) {
DatabaseHelper db;
ProductModel pm;
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.button1:
if (txtpname.getText().toString().equals("")
) {
Toast.makeText(AddReminders.this, "Please add values..",
Toast.LENGTH_LONG).show();
} else {
db = new DatabaseHelper(getApplicationContext());
db.getWritableDatabase();
pm = new ProductModel();
pm.idno = (txtpname.getText().toString());
Log.i("reminderidno", "" + pm.idno);
db.addProduct(pm);
Toast.makeText(AddReminders.this, "Record Added successfully.",
Toast.LENGTH_LONG).show();
finish();
}
break;
default:
break;
}
}
}
這裏是我的日誌
12-02 19:28:39.398: I/reminderidno(7827): [8888]
12-02 19:28:39.448: I/reminderidno(7827): [9999]
要清楚,我需要8888方括號 預先感謝您
你爲什麼使用字符串數組,因爲你在這兩個數組中只有一個字符串 – 2014-12-02 20:00:31
@ pramod-yadav我不知道更好的方法來做到這一點,我是新來的,如果可以的話請幫助, – 2014-12-02 20:04:52
只需使用簡單字符串String versionNames =「8888」;同樣的versionNames1 – 2014-12-02 20:07:03