Get string from bundle android returns null

in your other activity, instead of using

filename = getIntent().getStringExtra("filename");

try using

filename = b.getString("filename");

That should solve your problem.


try this way

Intent intent = new Intent(first.this, second.class);

Bundle bundle = new Bundle();
bundle.putInt("index", index);

intent.putExtras(bundle);startActivity(intent);

then get it as

Bundle b = getIntent().getExtras();
int index = b.getInt("index");