当我在Android模拟器上发送短信时,会转到内容提供商:
content://sms/sent
Run Code Online (Sandbox Code Playgroud)
对?
所以我想从内容提供商处获取最后发送的短信.所以我使用了这个Uri,你可以在上面看到,我使用了方法查询,内容解析器对象.我得到了光标,并使用了movetofirst()方法,所以我会有最后发送的短信.检查下面的代码.
package com.sys;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.net.Uri;
import android.database.Cursor;
public class SMS extends Activity {
Button btnVerSms;
EditText txtFinal;
final Uri CONTENT_URI = Uri.parse("content://sms/sent");
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnVerSms= (Button)findViewById(R.id.btnVerSms);
txtFinal = (EditText)findViewById(R.id.txtFinal);
btnVerSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Cursor cursor = getContentResolver().query(CONTENT_URI, null, null, null, null);
String …Run Code Online (Sandbox Code Playgroud) 我使用的是CursorAdapter和ContentProvider,我想用CursorLoader,所以我重新配置我的项目目标API 11,并设置分-SDK-版本7.但是它崩溃时Activity调用子Activity,它使用CursorLoader.错误NoClassDefFoundError通过IllegalStateException.
我的问题是,即使我们有相同的配置,我们可以在以前的Android版本中使用Honeycomb API吗?
java android android-contentprovider android-loadermanager android-cursorloader
我用谷歌搜索了几次,但找不到我要找的东西。Android 为每条短信分配一个 id。我想知道这个 ID 是否总是唯一的?我可以依靠它来识别短信还是应该自己分配?
谢谢 :)
我在我的android应用程序中实现了可搜索的建议,并在自动完成文本中显示结果(我已经与搜索视图绑定).
以下是我的配置
searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable
xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="Search Name"
android:searchSuggestAuthority="com.mdb.db"
android:searchSuggestIntentAction="android.intent.action.VIEW" />
Run Code Online (Sandbox Code Playgroud)
这是我的匹配器
MATCHER.addURI(MyApp.AUTHORITY,SearchManager.SUGGEST_URI_PATH_QUERY, DB.NAME.SEARCH_SUGGEST);
MATCHER.addURI(MyApp.AUTHORITY,SearchManager.SUGGEST_URI_PATH_QUERY+"/*", DB.NAME.SEARCH_SUGGEST);
Run Code Online (Sandbox Code Playgroud)
现在的问题是,当我输入文本并查看自动完成列表并点击自动完成内的任何项目时,它会打开相同的活动,而不是在a中设置所选项目searchview.我不知道如何解决这个问题.
为每个表创建 ContentProvider 是否可以意味着单个应用程序中存在多个内容提供程序?
\n\n出于各种原因我想这样做。
\n\n1-随着我的应用程序的增长,单个 ContentProvider 类变得臃肿且混乱。
\n\n2-我不想与另一个应用程序共享整个 ContentProvider 类。我只想共享几个或仅一张表。\xef\xbb\xbf
\n我是android开发的初学者,需要有关ContentProvider的帮助.
public class My Application extends ContentProvider {}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从Kotlin文件查询内容提供者。请参见下面的代码:
var URI = Uri.parse("content://myprovider")
var nameUri = Uri.withAppendedPath(URI, "name")
cursor = contentResolver.query(nameUri, null, null, null, null)
Run Code Online (Sandbox Code Playgroud)
When I run this code, I am getting below error
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter projection
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
at android.content.ContentResolver.query(ContentResolver.java:802)
Run Code Online (Sandbox Code Playgroud)
Now, when I checked the query method signature in ContentResolver class, this is what it is
public final @Nullable Cursor query(@RequiresPermission.Read @NonNull Uri uri,
@Nullable String[] projection, @Nullable String selection,
@Nullable String[] …Run Code Online (Sandbox Code Playgroud) android android-contentresolver android-contentprovider kotlin
我遇到了内容提供商的问题.我正在尝试创建一个内容提供商.
public static final Uri CONTENT_URI =
Uri.parse("content://data/data/one.two/databases");
Run Code Online (Sandbox Code Playgroud)
这导致我的数据库,因为我想从中提取数据并在列表视图中显示它.之后,我必须编辑插入提供程序的清单
<provider android:name="databases789"
android:grantUriPermissions="true"
android:enabled="true"
android:syncable="true"
android:authorities="one.two.databases" >
</provider>
Run Code Online (Sandbox Code Playgroud)
但是,它显示了没有one.two.databases存在的错误.