【发布时间】:2020-01-23 21:49:44
【问题描述】:
ContentValues values = new ContentValues();
values.put("username", username);
values.put("system", "NULL");
values.put("local_password", "NULL");
Uri test = getContentResolver().insert(DataProvider.PROFILES_URI, values);
这总是返回 null 进行测试。我在 logcat 中没有任何异常。不应该是网址吗?该行被插入到数据库中,稍后在其他地方检索它。
【问题讨论】:
-
这取决于 DataProvider 的实现......这个实现是谁做的?
-
我做了,如果需要,代码可用。 DataProvider.PROFILES_URI 定义为
public static final Uri PROFILES_URI = Uri.parse("content://com.nuance.dmmr.marshall.dataprovider/profiles");,正如我所说,正在插入该行。 -
所以...您的代码 DataProvide 看起来像这样
@Override public Uri insert(Uri uri, ContentValues values) { /* ...insert to db goes here... */ return null;}并且它的行为应该如此。那你的问题在哪里? -
嘿,问题出在我的耳朵之间。当然,如果我重写超级实现 I 必须返回我想要的。感谢您指出显而易见的。如果你想把这个作为答案,我很乐意接受。