【发布时间】:2022-10-15 05:53:34
【问题描述】:
我正在使用这样的 Firebase 模型类。我正在尝试在用户 Uid 下检索文件名和文件 URL。如果有人需要更多信息,请问我。
public class model {
public String filename;
public String fileurl;
public model() {
}
public model(String filename, String fileurl) {
this.filename = filename;
this.fileurl = fileurl;
}
public String getFilename() {
return filename;
}
public String getFileurl() {
return fileurl;
}
public void setFilename(String filename) {
this.filename = filename;
}
public void setFileurl(String fileurl) {
this.fileurl = fileurl;
}
我在我的代码中使用 FirebaseUI recyclerview。我想在用户 UID 下检索数据,请纠正我的错误。我为此做了一个适配器。
FirebaseRecyclerOptions<model> options =
new FirebaseRecyclerOptions.Builder<model>()
.setQuery(FirebaseDatabase.getInstance().getReference().child("Users"),model.class)
.build();
adapter=new myadapter(options);
recview.setAdapter(adapter);
这是我的实时数据库结构。稍后我会将 fileurl 放入我的 firebase 数据库中。
这是 manifest.xml 文件。 manifest.xml 文件中有任何问题。
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:usesCleartextTraffic="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MySchool"
tools:targetApi="31">
<activity
android:name=".ebooks"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".viewpdf"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".ProfileView"
android:exported="false" />
<activity
android:name=".OTPActivity"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
<activity
android:name=".PhoneAuthentication"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
<activity
android:name=".SplashScreen"
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
【问题讨论】:
-
“我稍后会将 fileurl 放入我的 firebase 数据库”是什么意思?如果你不给它那些字段,它就不会得到那些字段。就这么简单。您需要添加它们才能在您的应用中获取值
标签: java android firebase google-cloud-platform firebase-realtime-database