小编Kam*_*mil的帖子

Android:覆盖 API 29 中现有 URI 的文件

以下代码获取 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为空,则不会保存文件。

有什么帮助吗?

android uri outputstream file android-contentresolver

4
推荐指数
1
解决办法
1520
查看次数

外键是否需要引用主键或候选键?

我有两个相互矛盾的外键定义。

来自维基百科

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

哪个是哪个?外键是否需要引用主键或候选键?

database foreign-keys primary-key

3
推荐指数
1
解决办法
7492
查看次数