Java 类android.provider.BaseColumns 实例源码

项目:simple-share-android    文件:ExplorerProvider.java   
private void createTablesV2(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + TABLE_CONNECTION + " (" +
            BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
            ConnectionColumns.NAME + " TEXT," +
            ConnectionColumns.TYPE + " TEXT," +
            ConnectionColumns.SCHEME + " TEXT," +
            ConnectionColumns.PATH + " TEXT," +
            ConnectionColumns.HOST + " TEXT," +
            ConnectionColumns.PORT + " INTEGER," +
            ConnectionColumns.USERNAME + " TEXT," +
            ConnectionColumns.PASSWORD + " TEXT," +
            ConnectionColumns.ANONYMOUS_LOGIN + " BOOLEAN," +
            "UNIQUE (" + ConnectionColumns.NAME + ", " + ConnectionColumns.HOST + ", " + ConnectionColumns.PATH +  ") ON CONFLICT REPLACE " +
            ")");

    addDefaultServer(db);
}
项目:CSipSimple    文件:FavLoader.java   
/**
 * Creates a cursor that contains contacts group corresponding to an sip
 * account.
 */
private Cursor createContentCursorFor(SipProfile account) {
    Cursor c = null;
    if(!TextUtils.isEmpty(account.android_group)) {
        c = ContactsWrapper.getInstance().getContactsByGroup(getContext(), account.android_group);
    }
    if(c != null) {
        return c;
    }
    MatrixCursor mc = new MatrixCursor (new String[] {
            BaseColumns._ID, 
            ContactsWrapper.FIELD_TYPE
    });
    mc.addRow(new Object[] {account.id, ContactsWrapper.TYPE_CONFIGURE});
    return mc;
}
项目:aos-MediaLib    文件:IndexHelper.java   
public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {
    if (loaderID == mLoaderManagerId && (mUri != null || mVideoId != -1)) {
        String selection = (mVideoId != -1 ? BaseColumns._ID : MediaColumns.DATA) + "=?";
        if(LoaderUtils.mustHideUserHiddenObjects())
            selection += " AND "+LoaderUtils.HIDE_USER_HIDDEN_FILTER;
        CursorLoader cursorLoader =  new CursorLoader(
                mContext,
                VideoStore.Video.Media.EXTERNAL_CONTENT_URI,
                VideoDbInfo.COLUMNS,selection
                 ,
                new String [] {(mVideoId != -1 ? String.valueOf(mVideoId) : mUri.toString())},
                null);
        if(mLoaderManager==null)
            cursorLoader.registerListener(loaderID, this);
        return cursorLoader;
    }
    return null;
}
项目:simple-share-android    文件:ConnectionsFragment.java   
public boolean onPopupMenuItemClick(MenuItem item, int position) {
    final Cursor cursor = mAdapter.getItem(position);
    int connection_id = getCursorInt(cursor, BaseColumns._ID);
    NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
    final int id = item.getItemId();
    switch (id) {
        case R.id.menu_edit:
            editConnection(connection_id);
            return true;
        case R.id.menu_delete:
            if(!networkConnection.type.equals(SERVER)) {
                deleteConnection(connection_id);
            } else {
                ((BaseActivity)getActivity())
                        .showSnackBar("Default server connection can't be deleted",
                                Snackbar.LENGTH_SHORT);
            }
            return true;
        default:
            return false;
    }
}
项目:Veggietizer    文件:DatabaseAccess.java   
/**
 * Returns all stored meat dishes that belong to the specified period of time.
 * Consider calling this method from within an {@link AsyncTask} to prevent the UI from freezing.
 *
 * @param periodStart The first day of the period (inclusive) or <code>null</code> if no start limit.
 * @param periodEnd The last day of the period (inclusive) or <code>null</code> if no end limit.
 * @return The stored meat dishes, ordered by date (latest first), or an empty array if none available.
 */
public MeatDish[] getMeatDishes(Date periodStart, Date periodEnd) {
    Cursor cursor = getMeatDishesCursor(periodStart, periodEnd);
    MeatDish[] meatDishes = new MeatDish[cursor.getCount()];

    cursor.moveToFirst();
    for (int i = 0; i < meatDishes.length; ++i) {
        int id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
        String dateStr = cursor.getString(cursor.getColumnIndex(MeatDishContract.COLUMN_NAME_DATE));
        String sort = cursor.getString(cursor.getColumnIndex(MeatDishContract.COLUMN_NAME_SORT_OF_MEAT));
        int amount = cursor.getShort(cursor.getColumnIndex(MeatDishContract.COLUMN_NAME_AMOUNT));
        Date date = DateParser.parseISO2014(dateStr, null);
        Meat meat = Meat.valueOf(sort);
        meatDishes[i] = new MeatDish(id, date, meat, amount);
        cursor.moveToNext();
    }

    cursor.close();       
    return meatDishes;
}
项目:easyfilemanager    文件:ConnectionsFragment.java   
public boolean onPopupMenuItemClick(MenuItem item, int position) {
    final Cursor cursor = mAdapter.getItem(position);
    int connection_id = getCursorInt(cursor, BaseColumns._ID);
    NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
    final int id = item.getItemId();
    switch (id) {
        case R.id.menu_edit:
            editConnection(connection_id);
            return true;
        case R.id.menu_delete:
            if(!networkConnection.type.equals(SERVER)) {
                deleteConnection(connection_id);
            } else {
                ((BaseActivity)getActivity())
                        .showSnackBar("Default server connection can't be deleted",
                                Snackbar.LENGTH_SHORT);
            }
            return true;
        default:
            return false;
    }
}
项目:easyfilemanager    文件:NetworkConnection.java   
public static boolean deleteConnection(Context context, int id) {
    try {
        int resultId = context.getContentResolver()
                .delete(ExplorerProvider.buildConnection(),
                        BaseColumns._ID + "=? "
                        , new String[]{Integer.toString(id)});
        if (0 != resultId) {
            return true;
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed to load some roots from " + NetworkStorageProvider.AUTHORITY + ": " + e);
    }

    return false;
}
项目:simple-share-android    文件:NetworkStorageProvider.java   
public void updateConnections() {
    Cursor cursor = null;
    mRoots.clear();
    try {
        cursor = getContext().getContentResolver().query(ExplorerProvider.buildConnection(), null, null, null, null);
        while (cursor.moveToNext()) {
            int id = getCursorInt(cursor, BaseColumns._ID);
            NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
            mRoots.put(networkConnection.getHost(), networkConnection);
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed to load some roots from " + ExplorerProvider.AUTHORITY + ": " + e);
        CrashReportingManager.logException(e);
    } finally {
        IoUtils.closeQuietly(cursor);
    }

    notifyRootsChanged(getContext());
}
项目:easyfilemanager    文件:ExplorerProvider.java   
private void createTablesV2(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + TABLE_CONNECTION + " (" +
            BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
            ConnectionColumns.NAME + " TEXT," +
            ConnectionColumns.TYPE + " TEXT," +
            ConnectionColumns.SCHEME + " TEXT," +
            ConnectionColumns.PATH + " TEXT," +
            ConnectionColumns.HOST + " TEXT," +
            ConnectionColumns.PORT + " INTEGER," +
            ConnectionColumns.USERNAME + " TEXT," +
            ConnectionColumns.PASSWORD + " TEXT," +
            ConnectionColumns.ANONYMOUS_LOGIN + " BOOLEAN," +
            "UNIQUE (" + ConnectionColumns.NAME + ", " + ConnectionColumns.HOST + ", " + ConnectionColumns.PATH +  ") ON CONFLICT REPLACE " +
            ")");

    addDefaultServer(db);
}
项目:Hello-Music-droid    文件:MusicPlayer.java   
public static final long[] getSongListForArtist(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    final String selection = MediaStore.Audio.AudioColumns.ARTIST_ID + "=" + id + " AND "
            + MediaStore.Audio.AudioColumns.IS_MUSIC + "=1";
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
            MediaStore.Audio.AudioColumns.ALBUM_KEY + "," + MediaStore.Audio.AudioColumns.TRACK);
    if (cursor != null) {
        final long[] mList = SongLoader.getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
项目:Hello-Music-droid    文件:MusicPlayer.java   
public static final long[] getSongListForAlbum(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    final String selection = MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + id + " AND " + MediaStore.Audio.AudioColumns.IS_MUSIC
            + "=1";
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
            MediaStore.Audio.AudioColumns.TRACK + ", " + MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null) {
        final long[] mList = SongLoader.getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
项目:ContentPal    文件:RowCount.java   
@Override
public Integer value()
{
    Cursor cursor = null;
    try
    {
        cursor = mView.rows(EmptyUriParams.INSTANCE, new SingleColProjection(BaseColumns._ID), mPredicate, Absent.<String>absent());
        return cursor.getCount();
    }
    catch (RemoteException e)
    {
        throw new RuntimeException("Query failed", e);
    }
    finally
    {
        if (cursor != null)
        {
            cursor.close();
        }
    }
}
项目:aos-MediaLib    文件:MusicProvider.java   
private static void fillArtistAlbumsMap() {
    sArtistAlbumsMap.put(BaseColumns._ID, "audio.album_id AS " +
            BaseColumns._ID);
    sArtistAlbumsMap.put(AlbumColumns.ALBUM, "album");
    sArtistAlbumsMap.put(AlbumColumns.ALBUM_KEY, "album_key");
    sArtistAlbumsMap.put(AlbumColumns.FIRST_YEAR, "MIN(year) AS " +
            AlbumColumns.FIRST_YEAR);
    sArtistAlbumsMap.put(AlbumColumns.LAST_YEAR, "MAX(year) AS " +
            AlbumColumns.LAST_YEAR);
    sArtistAlbumsMap.put(AudioColumns.ARTIST, "artist");
    sArtistAlbumsMap.put(AudioColumns.ARTIST_ID, "artist");
    sArtistAlbumsMap.put(AudioColumns.ARTIST_KEY, "artist_key");
    sArtistAlbumsMap.put(AlbumColumns.NUMBER_OF_SONGS, "count(*) AS " +
            AlbumColumns.NUMBER_OF_SONGS);
    sArtistAlbumsMap.put(AlbumColumns.ALBUM_ART, "album_art._data AS " +
            AlbumColumns.ALBUM_ART);
    sArtistAlbumsMap.put(AlbumColumns.IS_ARCHOS_FAVORITE, "audio.Archos_favorite_album AS " +
            AlbumColumns.IS_ARCHOS_FAVORITE);
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * @param cursor The {@link Cursor} used to perform our query.
 * @return The song list for a MIME type.
 */
public static final long[] getSongListForCursor(Cursor cursor) {
    if (cursor == null) {
        return sEmptyList;
    }
    final int len = cursor.getCount();
    final long[] list = new long[len];
    cursor.moveToFirst();
    int columnIndex = -1;
    try {
        columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.Members.AUDIO_ID);
    } catch (final IllegalArgumentException notaplaylist) {
        columnIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
    }
    for (int i = 0; i < len; i++) {
        list[i] = cursor.getLong(columnIndex);
        cursor.moveToNext();
    }
    cursor.close();
    cursor = null;
    return list;
}
项目:simple-share-android    文件:NetworkConnection.java   
public static NetworkConnection fromConnectionId(Context context, int id) {
    Cursor cursor = null;
    NetworkConnection networkConnection = null;
    try {
        cursor = context.getContentResolver()
                .query(ExplorerProvider.buildConnection(), null,
                        BaseColumns._ID + "=? "
                        , new String[]{Integer.toString(id)}, null);
        if (null != cursor && cursor.moveToFirst()) {
            networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed to load some roots from " + NetworkStorageProvider.AUTHORITY + ": " + e);
        CrashReportingManager.logException(e);
    } finally {
        IoUtils.closeQuietly(cursor);
    }

    return networkConnection;
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * @param context The {@link Context} to use.
 * @param id      The ID of the album.
 * @return The song list for an album.
 */
public static final long[] getSongListForAlbum(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    final String selection = AudioColumns.ALBUM_ID + "=" + id + " AND " + AudioColumns.IS_MUSIC
            + "=1";
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
            AudioColumns.TRACK + ", " + MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null) {
        final long[] mList = getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * Returns The ID for a playlist.
 *
 * @param context The {@link Context} to use.
 * @param name    The name of the playlist.
 * @return The ID for a playlist.
 */
public static final long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[]{
                    name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * Returns the Id for an artist.
 *
 * @param context The {@link Context} to use.
 * @param name    The name of the artist.
 * @return The ID for an artist.
 */
public static final long getIdForArtist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, ArtistColumns.ARTIST + "=?", new String[]{
                    name
            }, ArtistColumns.ARTIST);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * Returns the ID for an album.
 *
 * @param context    The {@link Context} to use.
 * @param albumName  The name of the album.
 * @param artistName The name of the artist
 * @return The ID for an album.
 */
public static final long getIdForAlbum(final Context context, final String albumName,
                                       final String artistName) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, AlbumColumns.ALBUM + "=? AND " + AlbumColumns.ARTIST + "=?", new String[]{
                    albumName, artistName
            }, AlbumColumns.ALBUM);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:KomaMusic    文件:MusicUtils.java   
/**
 * Gets the number of songs for a playlist
 *
 * @param context    The {@link Context} to use.
 * @param playlistId the id of the playlist
 * @return the # of songs in the playlist
 */
public static final int getSongCountForPlaylist(final Context context, final long playlistId) {
    Cursor c = context.getContentResolver().query(
            MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
            new String[]{BaseColumns._ID}, MusicUtils.MUSIC_ONLY_SELECTION, null, null);

    if (c != null) {
        int count = 0;
        if (c.moveToFirst()) {
            count = c.getCount();
        }
        c.close();
        c = null;
        return count;
    }

    return 0;
}
项目:KomaMusic    文件:AlbumDetailPresenter.java   
/**
 * @param context The {@link Context} to use.
 * @param albumId The Id of the album the songs belong to.
 * @return The {@link Cursor} used to run the query.
 */
private static final Cursor makeAlbumSongCursor(final Context context, final Long albumId) {
    // Match the songs up with the artist
    String selection = (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1") +
            " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''" +
            " AND " + MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + albumId;
    return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[]{
                    /* 0 */
                    BaseColumns._ID,
                    /* 1 */
                    MediaStore.Audio.AudioColumns.TITLE,
                    /* 2 */
                    MediaStore.Audio.AudioColumns.ARTIST,
                    /* 3 */
                    MediaStore.Audio.AudioColumns.ALBUM,
                    /* 4 */
                    MediaStore.Audio.AudioColumns.DURATION,
            }, selection, null,
            MediaStore.Audio.Media.TRACK + ", "
                    + MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
}
项目:financial-manager    文件:LocalAccountsDataSource.java   
@Override
public Observable<Account> getAccount(long accountId) {

    String projection[] = {
            AccountEntry._ID,
            AccountEntry.COLUMN_NAME_NAME
    };

    String sql = String.format(
            "SELECT %s FROM %s WHERE %s = ?",
            TextUtils.join(",", projection),
            AccountEntry.TABLE_NAME,
            BaseColumns._ID);

    return accountsDbHelper.createQuery(AccountEntry.TABLE_NAME, sql, String.valueOf(accountId))
            .mapToOneOrDefault(accountMapperFunction, null);
}
项目:RetroMusicPlayer    文件:PlaylistsUtil.java   
public static String getNameForPlaylist(@NonNull final Context context, final long id) {
    try {
        Cursor cursor = context.getContentResolver().query(
                EXTERNAL_CONTENT_URI,
                new String[]{MediaStore.Audio.PlaylistsColumns.NAME},
                BaseColumns._ID + "=?",
                new String[]{String.valueOf(id)},
                null);
        if (cursor != null) {
            try {
                if (cursor.moveToFirst()) {
                    return cursor.getString(0);
                }
            } finally {
                cursor.close();
            }
        }
    } catch (SecurityException ignored) {
    }
    return "";
}
项目:FuelUp    文件:JsonUtil.java   
private static JSONArray getJsonArrayFromCursor(final Cursor cursor) {
    JSONArray resultSet = new JSONArray();
    if (cursor != null) {
        while (cursor.moveToNext()) {
            JSONObject row = new JSONObject();
            for (int i = 0; i < cursor.getColumnCount(); i++) {
                if (cursor.getColumnName(i) != null
                        && !cursor.getColumnName(i).equals(ExpenseEntry.COLUMN_VEHICLE)
                        && !cursor.getColumnName(i).equals(FillUpEntry.COLUMN_VEHICLE)
                        && !cursor.getColumnName(i).equals(BaseColumns._ID)) {
                    try {
                        row.put(cursor.getColumnName(i), cursor.getString(i));
                    } catch (Exception e) {
                        Log.d(LOG_TAG, e.getMessage());
                    }
                }
            }
            resultSet.put(row);
        }
        cursor.close();
    }

    return resultSet;
}
项目:aos-Video    文件:AllTvshowsLoader.java   
@Override
public String[] getProjection() {
    return new String[] {
            VideoStore.MediaColumns.DATA,
            VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID + " AS " + BaseColumns._ID,
            VideoStore.Video.VideoColumns.SCRAPER_TITLE,
            VideoStore.Video.VideoColumns.SCRAPER_S_COVER,
            VideoStore.Video.VideoColumns.SCRAPER_E_SEASON,
            VideoStore.Video.VideoColumns.SCRAPER_S_PREMIERED,
            VideoStore.Video.VideoColumns.SCRAPER_S_STUDIOS,
            VideoStore.Video.VideoColumns.SCRAPER_S_PLOT,
            VideoStore.Video.VideoColumns.SCRAPER_E_ACTORS,
            VideoStore.Video.VideoColumns.SCRAPER_S_RATING,
            "max(" + VideoStore.Video.VideoColumns.DATE_ADDED + ") AS " + SORT_COUMN_LAST_ADDED,
            "COUNT(DISTINCT " + VideoStore.Video.VideoColumns.SCRAPER_E_SEASON + ") AS " + COLUMN_SEASON_COUNT,
            "COUNT(DISTINCT " + VideoStore.Video.VideoColumns.SCRAPER_E_EPISODE + ") AS " + COLUMN_EPISODE_COUNT,
            getTraktProjection(VideoStore.Video.VideoColumns.ARCHOS_TRAKT_SEEN),
            getTraktProjection(VideoStore.Video.VideoColumns.ARCHOS_TRAKT_LIBRARY),
    };
}
项目:aos-Video    文件:SeasonsLoader.java   
@Override
public String[] getProjection() {
    Log.d(TAG, "getProjection mShowId = " + mShowId);

    return new String[] {
            VideoStore.MediaColumns.DATA,
            VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID,
            VideoStore.Video.VideoColumns.SCRAPER_E_SEASON + " AS " + BaseColumns._ID,
            VideoStore.Video.VideoColumns.SCRAPER_TITLE,
            VideoLoader.COVER,
            VideoStore.Video.VideoColumns.SCRAPER_E_SEASON,
            "COUNT(DISTINCT " + VideoStore.Video.VideoColumns.SCRAPER_E_EPISODE + ") AS " + COLUMN_EPISODE_TOTAL_COUNT,
            "COUNT(CASE "+VideoStore.Video.VideoColumns.BOOKMARK+" WHEN "+PlayerActivity.LAST_POSITION_END+" THEN 1 ELSE NULL END) AS " + COLUMN_EPISODE_WATCHED_COUNT
    };

    // count() - count(CASE Archos_traktSeen WHEN 0 THEN 0 ELSE NULL END) AS watched,
}
项目:buildAPKsSamples    文件:DictionaryProvider.java   
private Cursor refreshShortcut(Uri uri) {
  /* This won't be called with the current implementation, but if we include
   * {@link SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} as a column in our suggestions table, we
   * could expect to receive refresh queries when a shortcutted suggestion is displayed in
   * Quick Search Box. In which case, this method will query the table for the specific
   * word, using the given item Uri and provide all the columns originally provided with the
   * suggestion query.
   */
  String rowId = uri.getLastPathSegment();
  String[] columns = new String[] {
      BaseColumns._ID,
      DictionaryDatabase.KEY_WORD,
      DictionaryDatabase.KEY_DEFINITION,
      SearchManager.SUGGEST_COLUMN_SHORTCUT_ID,
      SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID};

  return mDictionary.getWord(rowId, columns);
}
项目:PlusGram    文件:ContactsController.java   
private void performWriteContactsToPhoneBookInternal(ArrayList<TLRPC.TL_contact> contactsArray) {
    try {
        if (!hasContactsPermission()) {
            return;
        }
        Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, currentAccount.name).appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_TYPE, currentAccount.type).build();
        Cursor c1 = ApplicationLoader.applicationContext.getContentResolver().query(rawContactUri, new String[]{BaseColumns._ID, ContactsContract.RawContacts.SYNC2}, null, null, null);
        HashMap<Integer, Long> bookContacts = new HashMap<>();
        if (c1 != null) {
            while (c1.moveToNext()) {
                bookContacts.put(c1.getInt(1), c1.getLong(0));
            }
            c1.close();

            for (int a = 0; a < contactsArray.size(); a++) {
                TLRPC.TL_contact u = contactsArray.get(a);
                if (!bookContacts.containsKey(u.user_id)) {
                    TLRPC.User user = MessagesController.getInstance().getUser(u.user_id);
                    addContactToPhoneBook(user, false);
                }
            }
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
项目:aos-MediaLib    文件:MusicProvider.java   
private int forwardDelete(SQLiteDatabase db, String table, String selection, String[] selectionArgs) {
    String deleteIds = null;
    Cursor c = db.query(table, PROJECTION_IDS, selection, selectionArgs, null, null, null);
    if (c != null) {
        if (c.moveToFirst()) {
            deleteIds = c.getString(0);
        }
        c.close();
    }
    if (deleteIds == null || deleteIds.isEmpty())
        return 0;

    String where = BaseColumns._ID + " IN (" + deleteIds + ")";
    return mCr.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, where, null);
}
项目:downloadmanager    文件:DownloadProvider.java   
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {

    Log.d("dump", "Downloads updated in last hour:");

    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    final long modifiedAfter = System.currentTimeMillis() - DateUtils.HOUR_IN_MILLIS;
    final Cursor cursor = db.query(DB_TABLE, null,
            Downloads.Impl.COLUMN_LAST_MODIFICATION + ">" + modifiedAfter, null, null, null,
            Downloads.Impl._ID + " ASC");
    try {
        final String[] cols = cursor.getColumnNames();
        final int idCol = cursor.getColumnIndex(BaseColumns._ID);
        while (cursor.moveToNext()) {
            Log.d("dump", "Download #" + cursor.getInt(idCol) + ":");
            for (int i = 0; i < cols.length; i++) {
                // Omit sensitive data when dumping
                if (Downloads.Impl.COLUMN_COOKIE_DATA.equals(cols[i])) {
                    continue;
                }
                Log.d("dump", cols[i] + ", " + cursor.getString(i));
            }
        }
    } finally {
        cursor.close();
    }

}
项目:pokequest    文件:SuggestAdapter.java   
public void setSuggestions(List<String> suggestions) {
    final MatrixCursor c = new MatrixCursor(new String[]{ BaseColumns._ID, SUGGEST_COLUMN });
    for (int i = 0; i < suggestions.size(); ++i) {
        c.addRow(new Object[] {i, suggestions.get(i)});
    }
    changeCursor(c);
    mSuggestions = suggestions;
}
项目:aos-FileCoreLibrary    文件:Utils.java   
public static Uri getContentUriFromFileURI(Context context, Uri dataUri) {
    if(!"file".equals(dataUri.getScheme()))
        return null;
    dataUri = Uri.parse(dataUri.getPath());
    Cursor cursor = null;
    try {

        String where= MediaStore.MediaColumns.DATA +"= ?";
        String[] whereArg = { dataUri.toString() };
        String[] proj = { BaseColumns._ID};
        cursor = context.getContentResolver().query(MediaStore.Files.getContentUri("external"),  proj, where, whereArg, null);
        if(cursor==null) {
            return null;
        }
        int column_index = cursor.getColumnIndex( BaseColumns._ID);
        cursor.moveToFirst();
        if(cursor.getCount()==0
                ||column_index<0||cursor.getInt(column_index)==-1) {
            cursor.close();
            return null;
        }
        String uri = MediaStore.Files.getContentUri("external").toString()+"/"+cursor.getInt(column_index);
        cursor.close();
        return Uri.parse(uri);
    } finally {

    }
}
项目:unity-obb-downloader    文件:DownloadsDB.java   
public boolean updateMetadata(ContentValues cv) {
    final SQLiteDatabase sqldb = mHelper.getWritableDatabase();
    if (-1 == this.mMetadataRowID) {
        long newID = sqldb.insert(MetadataColumns.TABLE_NAME,
                MetadataColumns.APKVERSION, cv);
        if (-1 == newID)
            return false;
        mMetadataRowID = newID;
    } else {
        if (0 == sqldb.update(MetadataColumns.TABLE_NAME, cv,
                BaseColumns._ID + " = " + mMetadataRowID, null))
            return false;
    }
    return true;
}
项目:CSipSimple    文件:AccountFiltersListFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
     return new CursorLoader(getActivity(), SipManager.FILTER_URI, new String[] {
        BaseColumns._ID,
        Filter.FIELD_ACCOUNT,
           Filter.FIELD_ACTION,
           Filter.FIELD_MATCHES,
        Filter.FIELD_PRIORITY,
        Filter.FIELD_REPLACE
     }, Filter.FIELD_ACCOUNT + "=?", new String[] {Long.toString(accountId)}, Filter.DEFAULT_ORDER);

}
项目:CSipSimple    文件:FavLoader.java   
/**
 * Creates a cursor that contains a single row and maps the section to the
 * given value.
 */
private Cursor createHeaderCursorFor(SipProfile account) {
    MatrixCursor matrixCursor =
            new MatrixCursor(new String[] {
                    BaseColumns._ID, 
                    ContactsWrapper.FIELD_TYPE,
                    SipProfile.FIELD_DISPLAY_NAME,
                    SipProfile.FIELD_WIZARD,
                    SipProfile.FIELD_ANDROID_GROUP,
                    SipProfile.FIELD_PUBLISH_ENABLED,
                    SipProfile.FIELD_REG_URI,
                    SipProfile.FIELD_PROXY,
                    SipProfile.FIELD_ACC_ID
            });
    String proxies = "";
    if(account.proxies != null) {
        proxies = TextUtils.join(SipProfile.PROXIES_SEPARATOR, account.proxies);
    }
    matrixCursor.addRow(new Object[] {
            account.id,
            ContactsWrapper.TYPE_GROUP,
            account.display_name,
            account.wizard,
            account.android_group,
            account.publish_enabled,
            account.reg_uri,
            proxies,
            account.acc_id
    });
    return matrixCursor;
}
项目:CSipSimple    文件:FavAdapter.java   
@Override
public void onClick(View view) {
    ContactInfo ci = (ContactInfo) view.getTag();
    List<String> phones = ContactsWrapper.getInstance().getCSipPhonesContact(mContext, ci.contactId);
    boolean useCSip = true;
    String toCall = null;
    if(phones != null && phones.size() > 0) {
        toCall = phones.get(0);
    }else {
        List<Phone> cPhones = ContactsWrapper.getInstance().getPhoneNumbers(mContext, ci.contactId, ContactsWrapper.URI_ALLS);
        if(cPhones != null && cPhones.size() > 0) {
            toCall = cPhones.get(0).getNumber();
            useCSip = false;
        }
    }

    if(!TextUtils.isEmpty(toCall) ) {
        Cursor c = (Cursor) getItem((Integer) ci.userData);
        Long profileId = null;
        while(c.moveToPrevious()) {
            int cTypeIdx = c.getColumnIndex(ContactsWrapper.FIELD_TYPE);
            int cAccIdx = c.getColumnIndex(BaseColumns._ID);
            if(cTypeIdx >= 0 && cAccIdx >= 0) {
                if(c.getInt(cTypeIdx) == ContactsWrapper.TYPE_GROUP) {
                    profileId = c.getLong(cAccIdx);
                    break;
                }
            }
        }

        Intent it = new Intent(Intent.ACTION_CALL);
        it.setData(SipUri.forgeSipUri(useCSip ? SipManager.PROTOCOL_CSIP : SipManager.PROTOCOL_SIP, toCall));
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if(profileId != null) {
            it.putExtra(SipProfile.FIELD_ACC_ID, profileId);
        }
        mContext.startActivity(it);
    }
}
项目:MusicX-music-player    文件:AlbumLoader.java   
@Override
public List<Album> loadInBackground() {
    ArrayList<Album> albums = new ArrayList<>();
    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor musicCursor = getContext().getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, datacol, Where, selectionargs, sortorder);
        if (musicCursor != null && musicCursor.moveToFirst()) {
            int titleColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ALBUM);
            int idColumn = musicCursor.getColumnIndex(BaseColumns._ID);
            int artistColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ARTIST);
            int numOfSongsColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS);
            int albumfirstColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.FIRST_YEAR);
            do {
                String albumName = musicCursor.getString(titleColumn);
                long albumId = musicCursor.getLong(idColumn);
                String artistName = musicCursor.getString(artistColumn);
                int year = musicCursor.getInt(albumfirstColumn);
                int no = musicCursor.getInt(numOfSongsColumn);
                Album album = new Album();
                /**
                 * Setting Album Metadata
                 */
                album.setArtistName(artistName);
                album.setAlbumName(albumName);
                album.setId(albumId);
                album.setTrackCount(no);
                album.setYear(year);
                albums.add(album);
            } while (musicCursor.moveToNext());
            musicCursor.close();
        }
        if (musicCursor == null) {
            return Collections.emptyList();
        }
        return albums;
    } else {
        return null;
    }
}
项目:aos-MediaLib    文件:VideoStoreImportImpl.java   
/** copies data from Android's media db to ours */
private static int copyData (ContentResolver cr, String minId) {
    int imported = 0;
    String where = WHERE_ALL;
    String[] whereArgs = null;
    if (minId != null)  {
        where = WHERE_MIN_ID;
        whereArgs = new String[] { minId };
    }
    Cursor allFiles = CustomCursor.wrap(cr.query(MediaStore.Files.getContentUri("external"),
            FILES_PROJECTION, where, whereArgs, BaseColumns._ID));
    if (allFiles != null) {
        int count = allFiles.getCount();
        int ccount = allFiles.getColumnCount();
        if (count > 0) {
            // transaction size limited, acts like buffered output stream and auto-flushes queue
            BulkInserter inserter = new BulkInserter(VideoStoreInternal.FILES_IMPORT, cr, 2000);
            if (DBG) Log.d(TAG, "found items to import:" + count);
            while (allFiles.moveToNext()) {
                try {
                    ContentValues cv = new ContentValues(ccount);
                    DatabaseUtils.cursorRowToContentValues(allFiles, cv);
                    inserter.add(cv);
                } catch (IllegalStateException ignored) {} //we silently ignore empty lines - it means content has been deleted while scanning
            }
            imported = inserter.execute();
        }
        allFiles.close();
    }
    return imported;
}
项目:aos-MediaLib    文件:ScraperTrailer.java   
public static ScraperTrailer fromCursor(Cursor cur, Type type) {
    long imageId = cur.getLong(cur.getColumnIndexOrThrow(BaseColumns._ID));
    long remoteId = cur.getLong(cur.getColumnIndexOrThrow(type.movieIdColumn));
    String name = cur.getString(cur.getColumnIndexOrThrow(type.nameColumn));
    String videoKey = cur.getString(cur.getColumnIndexOrThrow(type.videoKeyColumn));
    String site = cur.getString(cur.getColumnIndexOrThrow(type.siteColumn));
    String lang = cur.getString(cur.getColumnIndexOrThrow(type.langColumn));

    ScraperTrailer image = new ScraperTrailer(type,  name, videoKey, site, lang);

    return image;
}
项目:easyfilemanager    文件:MediaDocumentsProvider.java   
private boolean isEmpty(Uri uri) {
    final ContentResolver resolver = getContext().getContentResolver();
    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        cursor = resolver.query(uri, new String[] {
                BaseColumns._ID }, null, null, null);
        return (cursor == null) || (cursor.getCount() == 0);
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
}