List of usage examples for android.webkit URLUtil isContentUrl
public static boolean isContentUrl(String url)
From source file:com.apptentive.android.sdk.util.Util.java
/** * This method creates a cached file exactly copying from the input stream. * * @param sourceUrl the source file path or uri string * @param localFilePath the cache file path string * @param mimeType the mimeType of the source inputstream * @return null if failed, otherwise a StoredFile object */// w w w . j a va2s. co m public static StoredFile createLocalStoredFile(String sourceUrl, String localFilePath, String mimeType) { InputStream is = null; try { Context context = ApptentiveInternal.getInstance().getApplicationContext(); if (URLUtil.isContentUrl(sourceUrl) && context != null) { Uri uri = Uri.parse(sourceUrl); is = context.getContentResolver().openInputStream(uri); } else { File file = new File(sourceUrl); is = new FileInputStream(file); } return createLocalStoredFile(is, sourceUrl, localFilePath, mimeType); } catch (FileNotFoundException e) { return null; } finally { ensureClosed(is); } }