本文整理汇总了Java中org.apache.cordova.file.LocalFilesystemURL类的典型用法代码示例。如果您正苦于以下问题:Java LocalFilesystemURL类的具体用法?Java LocalFilesystemURL怎么用?Java LocalFilesystemURL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalFilesystemURL类属于org.apache.cordova.file包,在下文中一共展示了LocalFilesystemURL类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToUri
import org.apache.cordova.file.LocalFilesystemURL; //导入依赖的package包/类
public static int writeToUri(Context context, Filesystem filesystem, LocalFilesystemURL inputURL, String data, int offset, boolean isBinary) throws NoModificationAllowedException {
Uri uri = filesystem.toNativeUri(inputURL);
OutputStream outputStream = null;
try {
outputStream = context.getContentResolver().openOutputStream(uri);
byte[] rawData;
if (isBinary) {
rawData = Base64.decode(data, Base64.DEFAULT);
} else {
rawData = data.getBytes(Charset.defaultCharset());
}
outputStream.write(rawData);
outputStream.flush();
outputStream.close();
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
context.sendBroadcast(intent);
return rawData.length;
} catch (Exception e) {
NoModificationAllowedException exception = new NoModificationAllowedException("Couldn't write to file given its content URI");
exception.initCause(e);
throw exception;
}
}