以下代码获取 aString并将内容保存到现有文件中Uri。这些代码在 Android API 29 之前运行良好。
public void saveFile(String text, Uri existingSourceUri)
{
try {
ContentResolver cr = getContentResolver();
OutputStream os = cr.openOutputStream(existingSourceUri);
os.write(text.getBytes());
os.flush();
os.close();
} catch (Exception e) {
//show error message
}
}
Run Code Online (Sandbox Code Playgroud)
对于 Android API 29+,行为不稳定。例如,如果第一次使用 some 调用该函数text,则该文件将被正确保存。但是,如果第二次text为空,则不会保存文件。
有什么帮助吗?
我有两个相互矛盾的外键定义。
来自维基百科
the foreign key is defined in a second table, but it refers to the primary key in the first table.
从我的讲义中:
Foreign key does not have to match a primary key but must match a candidate key in some relation
哪个是哪个?外键是否需要引用主键或候选键?