List of usage examples for android.provider BaseColumns _ID
String _ID
To view the source code for android.provider BaseColumns _ID.
Click Source Link
From source file:com.android.bluetooth.map.BluetoothMapContent.java
private void setHandle(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { long handle = c.getLong(c.getColumnIndex(BaseColumns._ID)); TYPE type = null;// www . j a v a2 s . c o m if (fi.msgType == FilterInfo.TYPE_SMS) { if (fi.phoneType == TelephonyManager.PHONE_TYPE_GSM) { type = TYPE.SMS_GSM; } else if (fi.phoneType == TelephonyManager.PHONE_TYPE_CDMA) { type = TYPE.SMS_CDMA; } } else if (fi.msgType == FilterInfo.TYPE_MMS) { type = TYPE.MMS; } else { type = TYPE.EMAIL; } if (D && type != null) Log.d(TAG, "setHandle: " + handle + " - Type: " + type.name()); e.setHandle(handle, type); }
From source file:org.restcomm.app.qoslib.Services.Events.EventUploader.java
/** * This method gets a cursor that contains all the signal strength rows that are associated with the given * event. It gets signal strength well before event, but only the last one before 30 seconds before event will be the start * @return// w ww . java2s .c o m */ private Cursor getSignalStrengthsAssociatedWithEvent(EventObj _event) { // Single signal strength table now Uri signalStrengthTable = UriMatch.SIGNAL_STRENGTHS.getContentUri(); String[] projection = new String[] { BaseColumns._ID, Tables.TIMESTAMP_COLUMN_NAME, Tables.SignalStrengths.SIGNAL, Tables.SignalStrengths.ECI0, Tables.SignalStrengths.SNR, Tables.SignalStrengths.BER, Tables.SignalStrengths.RSCP, Tables.SignalStrengths.SIGNAL2G, Tables.SignalStrengths.LTE_SIGNAL, Tables.SignalStrengths.LTE_RSRP, Tables.SignalStrengths.LTE_RSRQ, Tables.SignalStrengths.LTE_SNR, Tables.SignalStrengths.LTE_CQI, Tables.SignalStrengths.SIGNALBARS, Tables.SignalStrengths.ECN0, Tables.SignalStrengths.WIFISIGNAL, Tables.SignalStrengths.COVERAGE }; long startTime = _event.getEventTimestamp() - _event.getEventType().getPreEventStageTime() - 300000; Cursor cursor = owner.getDBProvider().query(signalStrengthTable, projection, Tables.SignalStrengths.TIMESTAMP + ">?", new String[] { String.valueOf(startTime) }, Tables.SignalStrengths.TIMESTAMP + " ASC"); return cursor; }
From source file:com.andrew.apollo.utils.MusicUtils.java
/** * Permanently deletes item(s) from the user's device. * * @param context The {@link Context} to use. * @param list The item(s) to delete./*from w w w . j ava2s .c om*/ */ public static void deleteTracks(final Context context, final long[] list, boolean showNotification) { if (list == null) { return; } final String[] projection = new String[] { BaseColumns._ID, MediaColumns.DATA, AudioColumns.ALBUM_ID }; final StringBuilder selection = new StringBuilder(); selection.append(BaseColumns._ID + " IN ("); for (int i = 0; i < list.length; i++) { selection.append(list[i]); if (i < list.length - 1) { selection.append(","); } } selection.append(")"); final Cursor c = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection.toString(), null, null); if (c != null) { // Step 1: Remove selected tracks from the current playlist, as well // as from the album art cache c.moveToFirst(); while (!c.isAfterLast()) { // Remove from current playlist. final long id = c.getLong(0); removeTrack(id); // Remove from the favorites playlist. FavoritesStore.getInstance(context).removeItem(id); // Remove any items in the recent's database RecentStore.getInstance(context).removeItem(c.getLong(2)); // Remove from all remaining playlists. removeSongFromAllPlaylists(context, id); c.moveToNext(); } // Step 2: Remove selected tracks from the database context.getContentResolver().delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, selection.toString(), null); // Step 3: Remove files from card FileSystem fs = Platforms.fileSystem(); c.moveToFirst(); while (!c.isAfterLast()) { final String name = c.getString(1); try { // File.delete can throw a security exception final File f = new File(name); if (!fs.delete(f)) { // I'm not sure if we'd ever get here (deletion would // have to fail, but no exception thrown) Log.e("MusicUtils", "Failed to delete file " + name); } c.moveToNext(); } catch (final Throwable ex) { c.moveToNext(); } } c.close(); UIUtils.broadcastAction(context, Constants.ACTION_FILE_ADDED_OR_REMOVED, new UIUtils.IntentByteExtra(Constants.EXTRA_REFRESH_FILE_TYPE, Constants.FILE_TYPE_AUDIO)); } if (showNotification) { try { final String message = makeLabel(context, R.plurals.NNNtracksdeleted, list.length); AppMsg.makeText(context, message, AppMsg.STYLE_CONFIRM).show(); } catch (Throwable ignored) { } } // We deleted a number of tracks, which could affect any number of // things // in the media content domain, so update everything. context.getContentResolver().notifyChange(Uri.parse("content://media"), null); // Notify the lists to update refresh(); }
From source file:com.google.android.apps.muzei.provider.MuzeiProvider.java
private int updateSource(@NonNull final Uri uri, final ContentValues values, final String selection, final String[] selectionArgs) { Context context = getContext(); if (context == null) { return 0; }/* w w w .ja va2s. co m*/ // Only Muzei can set the IS_SELECTED field if (values.containsKey(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED)) { if (!context.getPackageName().equals(getCallingPackage())) { Log.w(TAG, "Only Muzei can set the " + MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED + " column. Ignoring the value in " + values); values.remove(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED); } } final SQLiteDatabase db = databaseHelper.getWritableDatabase(); String finalWhere = selection; String[] finalSelectionArgs = selectionArgs; if (MuzeiProvider.uriMatcher.match(uri) == SOURCE_ID) { // If the incoming URI matches a single source ID, does the update based on the incoming data, but // modifies the where clause to restrict it to the particular source ID. finalWhere = DatabaseUtils.concatenateWhere(finalWhere, BaseColumns._ID + " = " + uri.getLastPathSegment()); } String callingPackageName = getCallingPackage(); if (!context.getPackageName().equals(callingPackageName)) { // Only allow other apps to update their own source finalWhere = DatabaseUtils.concatenateWhere(finalWhere, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + " LIKE ?"); finalSelectionArgs = DatabaseUtils.appendSelectionArgs(finalSelectionArgs, new String[] { callingPackageName + "/%" }); } int count = db.update(MuzeiContract.Sources.TABLE_NAME, values, finalWhere, finalSelectionArgs); if (count > 0) { notifyChange(uri); } else if (values.containsKey(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME)) { insertSource(MuzeiContract.Sources.CONTENT_URI, values); count = 1; } return count; }
From source file:com.android.bluetooth.map.BluetoothMapContent.java
private boolean matchRecipientMms(Cursor c, FilterInfo fi, String recip) { boolean res;/* w ww . j a va 2s. c om*/ long id = c.getLong(c.getColumnIndex(BaseColumns._ID)); String phone = getAddressMms(mResolver, id, MMS_TO); if (phone != null && phone.length() > 0) { if (phone.matches(recip)) { if (D) Log.d(TAG, "match recipient phone = " + phone); res = true; } else { String name = getContactNameFromPhone(phone); if (name != null && name.length() > 0 && name.matches(recip)) { if (D) Log.d(TAG, "match recipient name = " + name); res = true; } else { res = false; } } } else { res = false; } return res; }
From source file:com.android.bluetooth.map.BluetoothMapContent.java
private boolean matchOriginatorMms(Cursor c, FilterInfo fi, String orig) { boolean res;/*from w w w . jav a 2 s. c o m*/ long id = c.getLong(c.getColumnIndex(BaseColumns._ID)); String phone = getAddressMms(mResolver, id, MMS_FROM); if (phone != null && phone.length() > 0) { if (phone.matches(orig)) { if (D) Log.d(TAG, "match originator phone = " + phone); res = true; } else { String name = getContactNameFromPhone(phone); if (name != null && name.length() > 0 && name.matches(orig)) { if (D) Log.d(TAG, "match originator name = " + name); res = true; } else { res = false; } } } else { res = false; } return res; }
From source file:com.gelakinetic.mtgfam.helpers.CardDbAdapter.java
/** * Builds a map for all columns that may be requested, which will be given * to the SQLiteQueryBuilder. This is a good way to define aliases for * column names, but must include all columns, even if the value is the key. * This allows the ContentProvider to request columns w/o the need to know * real column names and create the alias itself. *///from w w w. ja va 2 s .co m private static HashMap<String, String> buildColumnMap() { HashMap<String, String> map = new HashMap<String, String>(); map.put(KEY_NAME, KEY_NAME); map.put(BaseColumns._ID, "rowid AS " + BaseColumns._ID); map.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, "rowid AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID); map.put(SearchManager.SUGGEST_COLUMN_SHORTCUT_ID, "rowid AS " + SearchManager.SUGGEST_COLUMN_SHORTCUT_ID); return map; }
From source file:com.andrew.apolloMod.service.ApolloService.java
private boolean makeAutoShuffleList() { ContentResolver res = getContentResolver(); Cursor c = null;/*from www. j a v a 2 s .c om*/ try { c = res.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[] { BaseColumns._ID }, AudioColumns.IS_MUSIC + "=1", null, null); if (c == null || c.getCount() == 0) { return false; } int len = c.getCount(); long[] list = new long[len]; for (int i = 0; i < len; i++) { c.moveToNext(); list[i] = c.getLong(0); } mAutoShuffleList = list; return true; } catch (RuntimeException ex) { } finally { if (c != null) { c.close(); } } return false; }
From source file:com.android.mms.ui.MessageUtils.java
/** M: * Return the current storage status.//from w ww.j a va2s . c o m */ public static String getStorageStatus(Context context) { /// M: we need count only final String[] PROJECTION = new String[] { BaseColumns._ID, Mms.MESSAGE_SIZE }; final ContentResolver cr = context.getContentResolver(); final Resources res = context.getResources(); Cursor cursor = null; StringBuilder buffer = new StringBuilder(); // Mms count cursor = cr.query(Mms.CONTENT_URI, PROJECTION, null, null, null); int mmsCount = 0; if (cursor != null) { mmsCount = cursor.getCount(); } buffer.append(res.getString(R.string.storage_dialog_mms, mmsCount)); buffer.append("\n"); //Mms size long size = 0; if (cursor != null) { if (cursor.moveToFirst()) { do { size += cursor.getInt(1); } while (cursor.moveToNext()); } cursor.close(); } buffer.append(res.getString(R.string.storage_dialog_mms_size) + getHumanReadableSize(size)); buffer.append("\n"); // Attachment size size = getAttachmentSize(context); Log.d(TAG, "mms attachment size = " + size); final String sizeTag = getHumanReadableSize(size); buffer.append(res.getString(R.string.storage_dialog_attachments) + sizeTag); buffer.append("\n"); // Sms count cursor = cr.query(Sms.CONTENT_URI, PROJECTION, null, null, null); int smsCount = 0; if (cursor != null) { smsCount = cursor.getCount(); cursor.close(); } buffer.append(res.getString(R.string.storage_dialog_sms, smsCount)); buffer.append("\n"); // Database size final long dbsize = getDatabaseSize(context); buffer.append(res.getString(R.string.storage_dialog_database) + getHumanReadableSize(dbsize)); buffer.append("\n"); // Available space final StatFs datafs = new StatFs(Environment.getDataDirectory().getAbsolutePath()); final long availableSpace = (long) datafs.getAvailableBlocks() * datafs.getBlockSize(); buffer.append( res.getString(R.string.storage_dialog_available_space) + getHumanReadableSize(availableSpace)); return buffer.toString(); }
From source file:com.android.bluetooth.map.BluetoothMapContent.java
/** * Read out the mms parts and update the bMessage object provided i {@linkplain message} * @param id the content provider ID of the message * @param message the bMessage object to add the information to *///from w w w .j a v a2 s . c om private void extractEmailParts(long id, BluetoothMapbMessageMmsEmail message) { if (V) Log.v(TAG, "extractEmailParts with id " + id); String emailBody = ""; Uri uriAddress = Uri.parse("content://com.android.email.provider/body"); BluetoothMapbMessageMmsEmail.MimePart part; Cursor c = null; try { c = mResolver.query(uriAddress, Body.CONTENT_PROJECTION, BodyColumns.MESSAGE_KEY + "=?", new String[] { String.valueOf(id) }, null); } catch (Exception e) { Log.w(TAG, " EMAIL BODY QUERY FAILDED " + e); } if (c != null) { if (V) Log.v(TAG, "cursor not null"); if (c.moveToFirst()) { String textContentURI = c.getString(c.getColumnIndex(BodyColumns.TEXT_CONTENT_URI)); String htmlContentURI = c.getString(c.getColumnIndex(BodyColumns.HTML_CONTENT_URI)); if (textContentURI != null || htmlContentURI != null) { if (V) { Log.v(TAG, " EMAIL BODY textURI " + textContentURI); Log.v(TAG, " EMAIL BODY htmlURI " + htmlContentURI); } // GET FD to parse text or HTML content ParcelFileDescriptor fd = null; if (textContentURI != null) { try { Log.v(TAG, " TRY EMAIL BODY textURI " + textContentURI); fd = mResolver.openFileDescriptor(Uri.parse(textContentURI), "r"); } catch (FileNotFoundException e) { if (V) Log.w(TAG, e); } } if (fd == null) { if (htmlContentURI != null) { //Try HTML content if TEXT CONTENT NULL try { Log.v(TAG, " TRY EMAIL BODY htmlURI " + htmlContentURI); fd = mResolver.openFileDescriptor(Uri.parse(htmlContentURI), "r"); } catch (FileNotFoundException e) { if (V) Log.w(TAG, e); } catch (NullPointerException e) { if (V) Log.w(TAG, e); } String msgBody = null; if (fd != null) { msgBody = readEmailBodyForMessageFd(fd); } else { Log.w(TAG, " FETCH Email BODY File HTML URI FAILED"); } if (msgBody != null) { msgBody = msgBody.replaceAll("(?s)(<title>)(.*?)(</title>)", ""); msgBody = msgBody.replaceAll("(?s)(<style type=\"text/css\".*?>)(.*?)(</style>)", ""); CharSequence msgText = Html.fromHtml(msgBody); emailBody = msgText.toString(); emailBody = emailBody.replaceAll("(?s)(<!--)(.*?)(-->)", ""); // Solves problem with Porche Car-kit and Gmails. // Changes unix style line conclusion to DOS style emailBody = emailBody.replaceAll("(?s)(\\r)", ""); emailBody = emailBody.replaceAll("(?s)(\\n)", "\r\n"); } } else { Log.w(TAG, " FETCH Email BODY File HTML URI FAILED"); } } else { emailBody = readEmailBodyForMessageFd(fd); } //Set BMessage emailBody message.setEmailBody(emailBody); //Parts Long partId = c.getLong(c.getColumnIndex(BaseColumns._ID)); String contentType = "Content-Type: text/plain; charset=\"UTF-8\""; String name = null;//c.getString(c.getColumnIndex("displayName")); String text = null; if (D) Log.d(TAG, " _id : " + partId + "\n ct : " + contentType + "\n partname : " + name); part = message.addMimePart(); part.contentType = contentType; part.partName = name; try { if (emailBody != null) { part.data = emailBody.getBytes("UTF-8"); part.charsetName = "utf-8"; } } catch (NumberFormatException e) { Log.d(TAG, "extractEmailParts", e); part.data = null; part.charsetName = null; } catch (UnsupportedEncodingException e) { Log.d(TAG, "extractEmailParts", e); part.data = null; part.charsetName = null; } finally { } try { if (fd != null) fd.close(); } catch (IOException e) { } } else { Log.w(TAG, " FETCH Email BODY File URI FAILED"); } } c.close(); } message.updateCharset(); message.setEncoding("8BIT"); }