List of usage examples for android.net Uri withAppendedPath
public static Uri withAppendedPath(Uri baseUri, String pathSegment)
From source file:org.jamienicol.episodes.SeasonActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final int showId = args.getInt("showId"); final Uri uri = Uri.withAppendedPath(ShowsProvider.CONTENT_URI_SHOWS, String.valueOf(showId)); final String[] projection = { ShowsTable.COLUMN_NAME }; return new CursorLoader(this, uri, projection, null, null, null); }
From source file:com.kyakujin.android.autoeco.ui.ManualSettingActivity.java
private int connectToMapping(int manualId) { int mappingId = 0; if (manualId == 0) return mappingId; // Mapping??????? MappingDAO mappingDao = new MappingDAO(this); mappingId = mappingDao.searchMappingIdByManualId(manualId); // Mapping???? if (mappingId == 0) { // ??// ww w.j a v a2 s . c o m EcoDAO ecoDao = new EcoDAO(this); mEcoUri = ecoDao.insertDefaultEco(); // Mapping?? MappingModel mappingModel = new MappingModel(); mappingModel.setEcoid(Integer.valueOf(mEcoUri.getLastPathSegment())); mappingModel.setSchedid(0); mappingModel.setBatteryid(0); mappingModel.setManualid(manualId); mappingId = Integer.valueOf(mappingDao.insertMapping(mappingModel).getLastPathSegment()); } else { // Mapping??????? mEcoUri = Uri.withAppendedPath(EcoTbl.CONTENT_URI, String.valueOf(mappingDao.searchMappingIdByManualId(manualId))); } return mappingId; }
From source file:com.kylebeal.datedialogfragment.example.DateDetailFragment.java
/** * Switch to the date from the db from specified row * @param dateId - id of row containing date to display */// w w w . j a v a2s .co m public void updateDateId(long dateId) { mDateId = dateId; String[] projection = { "_id", "date" }; Uri queryUri = Uri.withAppendedPath(Uri.parse("content://" + DatesProvider.AUTHORITY + "/dates"), String.valueOf(dateId)); //get the specified date from the db Cursor dateCursor = getActivity().getContentResolver().query(queryUri, projection, null, null, null); Calendar date = getDate(dateCursor); setDate(date); updateUi(date); }
From source file:com.digiplex.extra.grantpermissiondemo.ContactsFragment.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { Uri baseUri;//ww w . ja v a 2 s . c o m if (mCurrentFilter != null) { baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurrentFilter)); } else { baseUri = Contacts.CONTENT_URI; } String selection = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND (" + Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); }
From source file:com.kyakujin.android.autoeco.ui.BatterySettingActivity.java
private int connectToMapping(int batteryId) { int mappingId = 0; if (batteryId == 0) return mappingId; // Mapping??????? MappingDAO mappingDao = new MappingDAO(this); mappingId = mappingDao.searchMappingIdByBatteryId(batteryId); // Mapping???? if (mappingId == 0) { // ??/* w w w . ja v a 2 s . c om*/ EcoDAO ecoDao = new EcoDAO(this); mEcoUri = ecoDao.insertDefaultEco(); // Mapping?? MappingModel mappingModel = new MappingModel(); mappingModel.setEcoid(Integer.valueOf(mEcoUri.getLastPathSegment())); mappingModel.setSchedid(0); mappingModel.setManualid(0); mappingModel.setBatteryid(batteryId); mappingId = Integer.valueOf(mappingDao.insertMapping(mappingModel).getLastPathSegment()); } else { // Mapping??????? mEcoUri = Uri.withAppendedPath(EcoTbl.CONTENT_URI, String.valueOf(mappingDao.searchEcoIdByBatteryId(batteryId))); } return mappingId; }
From source file:org.noorganization.instalistsynch.controller.local.dba.impl.ClientLogDbController.java
@Override public List<LogInfo> getElementByUuid(String _uuid, eActionType _actionType, eModelType _modelType, String _time) {/*w w w.ja v a 2s . c o m*/ Cursor cursor = mContentResolver.query(Uri.withAppendedPath(InstalistProvider.BASE_CONTENT_URI, "log"), LogInfo.COLUMN.ALL_COLUMNS, LogInfo.COLUMN.ITEM_UUID + " LIKE ? AND " + LogInfo.COLUMN.ACTION + " = ? AND " + LogInfo.COLUMN.MODEL + " = ? AND " + LogInfo.COLUMN.ACTION_DATE + " >= ? ", new String[] { _uuid, String.valueOf(_actionType.ordinal()), String.valueOf(_modelType.ordinal()), _time }, null); if (cursor == null) { return new ArrayList<>(); } if (cursor.getCount() == 0) { cursor.close(); return new ArrayList<>(); } List<LogInfo> list = new ArrayList<>(cursor.getCount()); cursor.moveToFirst(); try { do { int id = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.ID)); String uuid = cursor.getString(cursor.getColumnIndex(LogInfo.COLUMN.ITEM_UUID)); int action = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.ACTION)); eActionType actionType = eActionType.getTypeById(action); int model = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.MODEL)); eModelType modelType = eModelType.getTypeId(model); String date = cursor.getString(cursor.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)); list.add(new LogInfo(id, uuid, actionType, modelType, ISO8601Utils.parse(date, new ParsePosition(0)))); } while (cursor.moveToNext()); } catch (ParseException e) { e.printStackTrace(); return new ArrayList<>(); } finally { cursor.close(); } return list; }
From source file:au.com.cybersearch2.classyfy.MainActivityTest.java
public void test_parseIntent_action_view() throws Throwable { Intent intent = getNewIntent();//from w ww.j a va 2 s. c o m intent.setAction(Intent.ACTION_VIEW); Uri actionUri = Uri.withAppendedPath(ClassyFySearchEngine.CONTENT_URI, "34"); intent.setData(actionUri); setActivityIntent(intent); final MainActivity mainActivity = getActivity(); synchronized (mainActivity.taskHandle) { try { mainActivity.taskHandle.wait(10000); } catch (InterruptedException e) { e.printStackTrace(); } } assertThat(mainActivity.taskHandle.getStatus()).isEqualTo(WorkStatus.FINISHED); PropertiesListAdapter adapter = mainActivity.adapter; for (int i = 0; (i < adapter.getCount()) && (i < RECORD_DETAILS_ARRAY.length); i++) { Value item = (Value) adapter.getItem(i); assertThat(item.getName().equals(RECORD_DETAILS_ARRAY[i][0])); assertThat(item.getValue().equals(RECORD_DETAILS_ARRAY[i][1])); } ProgressBar spinner = mainActivity.progressFragment.getSpinner(); assertThat(spinner).isNotNull(); assertThat(spinner.getVisibility()).isEqualTo(View.GONE); }
From source file:org.openmrs.client.utilities.FormsLoaderUtil.java
private static Uri saveDefaultFormToDB(File formFile, String formFilePath) { Cursor cursor = null;//from ww w . j ava 2 s.c o m Uri uri = null; boolean isNew; try { String[] selectionArgs = { formFile.getAbsolutePath() }; String selection = OpenMRSFormsProviderAPI.FormsColumns.FORM_FILE_PATH + "=?"; cursor = Collect.getInstance().getContentResolver() .query(OpenMRSFormsProviderAPI.FormsColumns.CONTENT_URI, null, selection, selectionArgs, null); isNew = cursor.getCount() <= 0; if (isNew) { ContentValues v = new ContentValues(); v.put(OpenMRSFormsProviderAPI.FormsColumns.FORM_FILE_PATH, formFilePath); HashMap<String, String> formInfo = FileUtils.parseXML(formFile); v.put(OpenMRSFormsProviderAPI.FormsColumns.DISPLAY_NAME, formInfo.get(FileUtils.TITLE)); v.put(OpenMRSFormsProviderAPI.FormsColumns.JR_VERSION, formInfo.get(FileUtils.VERSION)); v.put(OpenMRSFormsProviderAPI.FormsColumns.JR_FORM_ID, formInfo.get(FileUtils.FORMID)); v.put(OpenMRSFormsProviderAPI.FormsColumns.SUBMISSION_URI, formInfo.get(FileUtils.SUBMISSIONURI)); v.put(OpenMRSFormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY, formInfo.get(FileUtils.BASE64_RSA_PUBLIC_KEY)); uri = Collect.getInstance().getContentResolver() .insert(OpenMRSFormsProviderAPI.FormsColumns.CONTENT_URI, v); } else { cursor.moveToFirst(); uri = Uri.withAppendedPath(OpenMRSFormsProviderAPI.FormsColumns.CONTENT_URI, cursor.getString(cursor.getColumnIndex(OpenMRSFormsProviderAPI.FormsColumns._ID))); } } finally { if (cursor != null) { cursor.close(); } } return uri; }
From source file:com.digitalarx.android.syncadapter.ContactSyncAdapter.java
private FileInputStream getContactVcard(String lookupKey) throws IOException { Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); AssetFileDescriptor fd = getContext().getContentResolver().openAssetFileDescriptor(uri, "r"); return fd.createInputStream(); }
From source file:org.lucasr.smoothie.samples.gallery.GalleryLoader.java
@Override public Bitmap loadItem(Long id) { Uri imageUri = Uri.withAppendedPath(Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(id)); Resources res = mContext.getResources(); int width = res.getDimensionPixelSize(R.dimen.image_width); int height = res.getDimensionPixelSize(R.dimen.image_height); Bitmap bitmap = decodeSampledBitmapFromResource(imageUri, width, height); if (bitmap != null) { mMemCache.put(id, bitmap);//from w ww . j a va2s . c om } return bitmap; }