Example usage for android.provider BaseColumns _ID

List of usage examples for android.provider BaseColumns _ID

Introduction

In this page you can find the example usage for android.provider BaseColumns _ID.

Prototype

String _ID

To view the source code for android.provider BaseColumns _ID.

Click Source Link

Document

The unique ID for a row.

Usage

From source file:org.catnut.plugin.fantasy.Photo.java

@Override
public String ddl() {
    Log.i(TAG, "create table [photos]...");
    StringBuilder ddl = new StringBuilder("CREATE TABLE ");
    ddl.append(TABLE).append("(").append(BaseColumns._ID).append(" int primary key,").append(name)
            .append(" text,").append(feature).append(" text,").append(description).append(" text,")
            .append(image_url).append(" int,").append(width).append(" int, ").append(height).append(" int")
            .append(")");
    return ddl.toString();
}

From source file:com.nadmm.airports.ListMenuFragment.java

@Override
protected void onListItemClick(ListView l, View v, int position) {
    Cursor c = (Cursor) getListAdapter().getItem(position);
    long id = c.getLong(c.getColumnIndex(BaseColumns._ID));
    String title = c.getString(c.getColumnIndex(ListMenuCursor.ITEM_TITLE));
    Class<?> clss = getItemFragmentClass(id);
    if (clss != null) {
        Bundle args = new Bundle();
        args.putString(ActivityBase.FRAGMENT_TAG_EXTRA, String.valueOf(id));
        args.putString(SUBTITLE_TEXT, title);
        args.putLong(MENU_ID, id);//from   ww  w  .  j a  v a2s  .c om
        getActivityBase().replaceFragment(clss, args);
    }
}

From source file:pl.selvin.android.listsyncsample.ui.ListsListFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            getActivity(), ListProvider.getHelper().getDirUri(Database.List.TABLE_NAME), new String[] {
                    BaseColumns._ID, Database.List.NAME, Database.List.DESCRIPTION, Database.List.CREATEDATE },
            null, null, Database.List.NAME);
}

From source file:com.packpublishing.asynchronousandroid.chapter4.PhoneListActivityRV.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[] columns = new String[] { BaseColumns._ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.NUMBER };

    return new CursorLoader(this, ContactsContract.CommonDataKinds.Phone.CONTENT_URI, columns, // projection
            null, // selection
            null, // selectionArgs
            null // sortOrder
    );// w  w  w.j ava2  s  . c om
}

From source file:org.cnx.android.quizcards.activities.DeckListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.deck_list);/*  w  w  w  .  j  ava2s . c o  m*/

    // Allow going back with ActionBar
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Get UI elements
    deckListView = (ListView) findViewById(R.id.deckListView);

    // Retrieve decks from the database, show in list
    getDecks();

    deckListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long resource_id) {
            // Get the id of the selected deck
            titlesCursor.moveToPosition(position);
            String id = titlesCursor.getString(titlesCursor.getColumnIndex(BaseColumns._ID));

            // Launch the deck
            Intent cardIntent = new Intent(getApplicationContext(), DeckDetailsActivity.class);
            cardIntent.putExtra(DECK_ID, id);
            startActivityForResult(cardIntent, DECK_INFO_REQUEST);
        }
    });
}

From source file:com.rks.musicx.data.loaders.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 {//  w ww  .  j  a  va 2  s  .  c  om
                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;
    }
}

From source file:org.cnx.quizcards.activities.DeckListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.deck_list);/*  w w w.j av  a 2 s  .  com*/

    // Allow going back with ActionBar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Get UI elements
    deckListView = (ListView) findViewById(R.id.deckListView);

    // Retrieve decks from the database, show in list
    getDecks();

    deckListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long resource_id) {
            // Get the id of the selected deck
            titlesCursor.moveToPosition(position);
            String id = titlesCursor.getString(titlesCursor.getColumnIndex(BaseColumns._ID));

            // Launch the deck
            Intent cardIntent = new Intent(getApplicationContext(), DeckDetailsActivity.class);
            cardIntent.putExtra(DECK_ID, id);
            startActivityForResult(cardIntent, DECK_INFO_REQUEST);
        }
    });
}

From source file:piuk.blockchain.android.ExchangeRatesProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    if (exchangeRates == null) {
        exchangeRates = getExchangeRates();

        if (exchangeRates == null)
            return null;
    }/*from  w ww. j  a v a2 s .  c om*/

    final MatrixCursor cursor = new MatrixCursor(
            new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_EXCHANGE_RATE });

    if (selection == null) {
        for (final Map.Entry<String, Double> entry : exchangeRates.entrySet())
            cursor.newRow().add(entry.getKey().hashCode()).add(entry.getKey()).add(entry.getValue());
    } else if (selection.equals(KEY_CURRENCY_CODE)) {

        if (selectionArgs == null)
            return null;

        final String code = selectionArgs[0];
        final Double rate = exchangeRates.get(code);
        cursor.newRow().add(code.hashCode()).add(code).add(rate);
    }

    return cursor;
}

From source file:org.cnx.android.quizcards.activities.CardListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.card_list);//  ww w.  j av a 2 s  . c o m

    // Allow going back with ActionBar
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Hide the keyboard at launch (as EditText will be focused automatically)
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // Get UI elements
    cardListView = (ListView) findViewById(R.id.cardListView);

    id = getIntent().getStringExtra(DECK_ID);

    getCards();

    cardListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long resource_id) {
            cardsCursor.moveToPosition(position);
            int row_id = cardsCursor.getInt(cardsCursor.getColumnIndex(BaseColumns._ID));
            String term = cardsCursor.getString(cardsCursor.getColumnIndex(TERM));
            String meaning = cardsCursor.getString(cardsCursor.getColumnIndex(MEANING));

            Intent cardEditIntent = new Intent(CardListActivity.this, CardEditorActivity.class);
            cardEditIntent.putExtra(BaseColumns._ID, row_id);
            cardEditIntent.putExtra(TERM, term);
            cardEditIntent.putExtra(MEANING, meaning);
            cardEditIntent.putExtra(DECK_ID, id);
            startActivityForResult(cardEditIntent, CARD_EDIT_REQUEST);
        }
    });
}

From source file:org.cnx.quizcards.activities.CardListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.card_list);//from   ww  w.  ja va 2s.  c  om

    // Allow going back with ActionBar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Hide the keyboard at launch (as EditText will be focused automatically)
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // Get UI elements
    cardListView = (ListView) findViewById(R.id.cardListView);

    id = getIntent().getStringExtra(DECK_ID);

    getCards();

    cardListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long resource_id) {
            cardsCursor.moveToPosition(position);
            int row_id = cardsCursor.getInt(cardsCursor.getColumnIndex(BaseColumns._ID));
            String term = cardsCursor.getString(cardsCursor.getColumnIndex(TERM));
            String meaning = cardsCursor.getString(cardsCursor.getColumnIndex(MEANING));

            Intent cardEditIntent = new Intent(CardListActivity.this, CardEditorActivity.class);
            cardEditIntent.putExtra(BaseColumns._ID, row_id);
            cardEditIntent.putExtra(TERM, term);
            cardEditIntent.putExtra(MEANING, meaning);
            cardEditIntent.putExtra(DECK_ID, id);
            startActivityForResult(cardEditIntent, CARD_EDIT_REQUEST);
        }
    });
}