从 2 个不同片段的 sqlite 中获取 2 table 的信息

get information from 2 table in sqlite from 2 different fragment

我有 2 个 tables:书籍和用户,现在我需要制作另一个 table 但它应该从书籍中获取一些字段,从用户中获取一些字段,我可以分开,但是当我转到另一个片段以从书中获取其他字段 table 用户名,我将其保存到字符串 returns null

   08-04 10:47:27.319 4004-4004/com.example.pars.amanatdari I/bookName: args : Bundle[{status=null, userName=jack, bookName=null}]
08-04 10:47:30.139 4004-4004/com.example.pars.amanatdari I/bookName: args : Bundle[{status=available, userName=null, bookName=نون والقلم}]

我到底该怎么做?我什至不知道要搜索什么

从片段发送数据:

    Bundle args = getArguments();
    String username = args.getString("userName");

并获取数据:

            Intent intent = getIntent();
            Bundle bundle = intent.getExtras();
            String bookName = bundle.getString("bookName");
            String bookStatus = bundle.getString("status");
            String bookUser = bundle.getString("userName");

            borrowFragment borrowFragment = new borrowFragment();
            Bundle args2 = new Bundle();
            args2.putString("bookName", bookName);
            args2.putString("status", bookStatus);
            args2.putString("userName", bookUser);
            Log.i("bookName", "args : " + args2);
            borrowFragment.setArguments(args2);
            getSupportFragmentManager().beginTransaction().add(R.id.frg_container, borrowFragment, "tag").commit();

这肯定会发生,因为在您访问书籍片段后包会变为空或被覆盖。所以可以做的是您可以从用户片段中获取值并将值传递给书籍片段,然后取两个值并转到下一个片段。数据要随身携带