當前位置: 首頁>>代碼示例>>Java>>正文


Java BaseColumns類代碼示例

本文整理匯總了Java中android.provider.BaseColumns的典型用法代碼示例。如果您正苦於以下問題:Java BaseColumns類的具體用法?Java BaseColumns怎麽用?Java BaseColumns使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BaseColumns類屬於android.provider包,在下文中一共展示了BaseColumns類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTablesV2

import android.provider.BaseColumns; //導入依賴的package包/類
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);
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:18,代碼來源:ExplorerProvider.java

示例2: createContentCursorFor

import android.provider.BaseColumns; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:20,代碼來源:FavLoader.java

示例3: onCreateLoader

import android.provider.BaseColumns; //導入依賴的package包/類
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;
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:19,代碼來源:IndexHelper.java

示例4: onPopupMenuItemClick

import android.provider.BaseColumns; //導入依賴的package包/類
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;
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:23,代碼來源:ConnectionsFragment.java

示例5: getMeatDishes

import android.provider.BaseColumns; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:mr-kojo,項目名稱:Veggietizer,代碼行數:28,代碼來源:DatabaseAccess.java

示例6: deleteConnection

import android.provider.BaseColumns; //導入依賴的package包/類
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;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:16,代碼來源:NetworkConnection.java

示例7: updateConnections

import android.provider.BaseColumns; //導入依賴的package包/類
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());
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:20,代碼來源:NetworkStorageProvider.java

示例8: getSongListForArtist

import android.provider.BaseColumns; //導入依賴的package包/類
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;
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:18,代碼來源:MusicPlayer.java

示例9: getSongListForAlbum

import android.provider.BaseColumns; //導入依賴的package包/類
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;
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:18,代碼來源:MusicPlayer.java

示例10: value

import android.provider.BaseColumns; //導入依賴的package包/類
@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();
        }
    }
}
 
開發者ID:dmfs,項目名稱:ContentPal,代碼行數:22,代碼來源:RowCount.java

示例11: fillArtistAlbumsMap

import android.provider.BaseColumns; //導入依賴的package包/類
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);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:20,代碼來源:MusicProvider.java

示例12: getSongListForCursor

import android.provider.BaseColumns; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:26,代碼來源:MusicUtils.java

示例13: fromConnectionId

import android.provider.BaseColumns; //導入依賴的package包/類
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;
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:21,代碼來源:NetworkConnection.java

示例14: getSongListForAlbum

import android.provider.BaseColumns; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:23,代碼來源:MusicUtils.java

示例15: getIdForPlaylist

import android.provider.BaseColumns; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:26,代碼來源:MusicUtils.java


注:本文中的android.provider.BaseColumns類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。