从一个活动传输文本到另一个活动

huangapple go评论83阅读模式
英文:

Transfer text from one activity to another

问题

我想在两个活动之间传输文本,还需要将该文本保存在本地数据库中。但它应该只在第一次时询问插入文本。请协助。

英文:

I want to transfer text from one activity to another and also need to save that text in local database. But it should ask to insert text for first time only. Please assist.

答案1

得分: 0

Sure, here's the translated code:

One Activity

Intent intent = new Intent(OneActivity.this, SecondActivity.class);
intent.putExtra("key", "value");
startActivity(intent);

Second Activity

String sessionId = getIntent().getStringExtra("key");
英文:

One Activity

Intent intent = new Intent(OneActivity.this, SeconActivity.class);
intent.putExtra("key","value");
startActivity(intent);

Second Activity

String sessionId = getIntent().getStringExtra("key");

huangapple
  • 本文由 发表于 2020年8月22日 12:54:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63532700.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定