I am a novice programmer, I wrote some code. I want get wallet_id in another class, but when I try this variable always have value = 0. In class ChooseWallet wallet_id sets value wallet_id well. But I don't know how get wallet_id in another class. Any idea?
public class ChooseWallet extends AppCompatActivity {
public int wallet_id;
DatabaseDEO db = new DatabaseDEO(this);
ListView choose;
private SimpleCursorAdapter adapter;
final String[] from = new String[] {Wallets.COLUMNS.name,Wallets.COLUMNS.surname};
final int[] to = new int[] {R.id.name, R.id.surname };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_wallet);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
choose = (ListView)findViewById(R.id.listselement);
choose.setEmptyView(findViewById(R.id.null));
Cursor cursor = db.fetch();
adapter = new SimpleCursorAdapter(this, R.layout.activity_see_record, cursor, from, to, 0);
adapter.notifyDataSetChanged();
choose.setAdapter(adapter);
choose.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
walllet_id = position+1;
}
});
}}