Search in sources :

Example 96 with ContentResolver

use of android.content.ContentResolver in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method defaultSchedulerReturnsNullIfSpecifiedSchedulerNull.

@Test
public void defaultSchedulerReturnsNullIfSpecifiedSchedulerNull() {
    StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).defaultScheduler(null).build();
    assertThat(storIOContentResolver.defaultScheduler()).isNull();
}
Also used : StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 97 with ContentResolver

use of android.content.ContentResolver in project robolectric by robolectric.

the class ContentProviderControllerTest method shouldRegisterWithContentResolver.

@Test
@Config(manifest = "src/test/resources/TestAndroidManifestWithContentProviders.xml")
public void shouldRegisterWithContentResolver() throws Exception {
    controller.create().get();
    ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
    ContentProviderClient client = contentResolver.acquireContentProviderClient("org.robolectric.authority2");
    client.query(Uri.parse("something"), new String[] { "title" }, "*", new String[] {}, "created");
    assertThat(controller.get().transcript).containsExactly("onCreate", "query for something");
}
Also used : ContentProviderClient(android.content.ContentProviderClient) ContentResolver(android.content.ContentResolver) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 98 with ContentResolver

use of android.content.ContentResolver in project roboguice by roboguice.

the class DefaultRoboModule method providesAndroidId.

@Provides
@Named(Settings.Secure.ANDROID_ID)
public String providesAndroidId() {
    String androidId = null;
    final ContentResolver contentResolver = application.getContentResolver();
    try {
        androidId = Secure.getString(contentResolver, Secure.ANDROID_ID);
    } catch (RuntimeException e) {
        // ignore Stub! errors for Secure.getString() when mocking in test cases since there's no way to mock static methods
        Log.e(DefaultRoboModule.class.getName(), "Impossible to get the android device Id. This may fail 'normally' when testing.", e);
    }
    if (!"".equals(androidId)) {
        return androidId;
    } else {
        throw new RuntimeException("No Android Id.");
    }
}
Also used : ContentResolver(android.content.ContentResolver) Named(com.google.inject.name.Named) Provides(com.google.inject.Provides)

Example 99 with ContentResolver

use of android.content.ContentResolver in project mechanoid by robotoworks.

the class AuthorsRecord method get.

public static AuthorsRecord get(long id) {
    Cursor c = null;
    ContentResolver resolver = Mechanoid.getContentResolver();
    try {
        c = resolver.query(Authors.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(), PROJECTION, null, null, null);
        if (!c.moveToFirst()) {
            return null;
        }
        return fromCursor(c);
    } finally {
        Closeables.closeSilently(c);
    }
}
Also used : Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Example 100 with ContentResolver

use of android.content.ContentResolver in project mechanoid by robotoworks.

the class IngredientsRecord method get.

public static IngredientsRecord get(long id) {
    Cursor c = null;
    ContentResolver resolver = Mechanoid.getContentResolver();
    try {
        c = resolver.query(Ingredients.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(), PROJECTION, null, null, null);
        if (!c.moveToFirst()) {
            return null;
        }
        return fromCursor(c);
    } finally {
        Closeables.closeSilently(c);
    }
}
Also used : Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Aggregations

ContentResolver (android.content.ContentResolver)1121 Uri (android.net.Uri)236 Cursor (android.database.Cursor)190 ContentValues (android.content.ContentValues)112 Intent (android.content.Intent)90 RemoteException (android.os.RemoteException)67 IOException (java.io.IOException)59 Context (android.content.Context)52 File (java.io.File)46 ArrayList (java.util.ArrayList)46 Resources (android.content.res.Resources)45 ComponentName (android.content.ComponentName)44 MediumTest (android.test.suitebuilder.annotation.MediumTest)37 PreferenceScreen (android.support.v7.preference.PreferenceScreen)33 Bitmap (android.graphics.Bitmap)31 ContentObserver (android.database.ContentObserver)28 FileNotFoundException (java.io.FileNotFoundException)28 PendingIntent (android.app.PendingIntent)25 MockContentResolver (android.test.mock.MockContentResolver)25 AssetFileDescriptor (android.content.res.AssetFileDescriptor)24