データベースとテーブルが作成される別の TryUIOpenHelper.java に定義がある RechargeActivity.java ファイルから inserttable メソッドを呼び出したいと思います。これへのより良い方法を知りたい..助けてください
public class RechargeActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rechtable);
RadioButton rb1 = (RadioButton) findViewById(R.id.rtt1);
RadioButton rb2 = (RadioButton) findViewById(R.id.rtt2);
final TextView amount = (TextView)findViewById(R.id.amount1);
final TextView talktime = (TextView)findViewById(R.id.talktime1);
final TextView validity = (TextView)findViewById(R.id.validity1);
final Button button = (Button) findViewById(R.id.done);
final TryUIOpenHelper helper=new TryUIOpenHelper(this);
final SQLiteDatabase dbDatabase=helper.getWritableDatabase();
final Date date = new Date();
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH); // 0 to 11
int day = now.get(Calendar.DAY_OF_MONTH);
String val=""+(day)+"/"+(month+1)+"/"+(year+1)+"";
validity.setText(val);
try{
rb1.setOnClickListener( new OnClickListener ()
{
public void onClick(View v)
{
//Error here: The method inserttable(SQLiteDatabase) is undefined for the type new View.OnClickListener(){}
inserttable(dbDatabase);
}
});
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
rb2.setOnClickListener( new OnClickListener ()
{
public void onClick(View v)
{
} } );
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent =
new Intent(RechargeActivity.this, NumForRecharge.class);
startActivity(intent);
}
});
//db.close();
}
}