Firebase实时数据库Android内部数据表示 [英] Firebase Realtime Database Internal Data Representation for Android
问题描述
但我需要存储在数据库中的用户的一些高度敏感的数据,我不想这样做纯文本。
所以,我已经加密数据,然后将它们存储到数据库中。我可以在Firebase控制台中看到加密的字符串。
问题
我需要检查并验证数据是如何在本地设备的Firebase数据库内部表示的,因为我在数据库中也存储了加密密钥。
我有 setPersistenceEnabled()
用于我的数据库,因此Firebase将这些数据本地存储在用户设备中。没有提到Firebase如何在内部执行此操作。是否将其存储为JSON文件或SQLite数据库(最有可能)。
我的尝试
为了深入研究这个问题,我尝试从应用程序中提取数据库。
我用过,
adb -d shellrun-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/
在我的终端中获取我的应用程序的所有数据库名称的列表,这是我得到的,
app-debug-xxxx.firebaseio.com_default
app-debug-xxxx.firebaseio.com_default-journal
crash_reports
crash_reports-journal
这些是我的数据库吗?无法从这些文件中读取数据,假设它们是SQLite数据库。
我个人认为,了解数据如何在Android内部表示是非常重要的这样我们可以做出更好的决定来存储我们的数据。
任何帮助都将得到高度赞赏?
在检查你提到的文件后,是的,它确实是一个SQLite数据库文件( app.firebaseio.com_default
)。
数据保存在 serverCache
表中,它包含2列: path
(TEXT)和值
(BLOB)。 path
是firebase数据库中的数据路径,类似于 / users / -KOasdbcde
和 value
是该路径的JSON值。
编辑
下面是该表的结构
The Story
I have an Android application which heavily relies on the Firebase Realtime Database. So far I do not have any problem using it.
But I need to store some highly sensitive data of the users in the database and I would not like to do that in plain text.
So, I have encrypted the data before storing them into the database. I can see the encrypted string in the Firebase Console.
The Problem
I need to check and verify how the data is internally represented by Firebase Database in my local device as I am storing the key for encryption in the database as well.
I have setPersistenceEnabled()
for my database and thus Firebase stores these data locally in the users device. It is nowhere mentioned how Firebase does this internally. Does it store it as a JSON file or a SQLite database (most probable).
My Attempt
To dig deeper into the problem, I tried to pull the databases from my app.
I used,
"adb -d shell "run-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/"
in my terminal to get a list of all database names for my app, and this is what I got,
app-debug-xxxx.firebaseio.com_default
app-debug-xxxx.firebaseio.com_default-journal
crash_reports
crash_reports-journal
So, these are my databases right? Are they regular SQLite databases? I was unable to read data from these files using the assumption that they are SQLite databases.
I personally think it is very important for us to know how the data is internally represented in Android so that we can make better decisions to store our data.
Any help will be highly appreciated?
After inspecting the file you mentioned, yes it's indeed a SQLite database file (app.firebaseio.com_default
).
The data is saved in serverCache
table and it contains 2 columns: path
(TEXT) and value
(BLOB). path
is the path to the data in firebase database, something like /users/-KOasdbcde
and the value
is the JSON value of that path.
EDIT
Here's the structure of that table
这篇关于Firebase实时数据库Android内部数据表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!