如何创建从谷歌玻璃应用程序的文件?

编程入门 行业动态 更新时间:2024-10-19 16:23:05
本文介绍了如何创建从谷歌玻璃应用程序的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有在玻璃上运行的应用程序。我想我的应用程序在运行时创建文件和能够写/从这些文件中读取数据到/。谁能告诉我一个办法做到这一点?难道Android的openFileOutput()玻璃工作?

I have an application that runs on glass. I want my application to create files at run time and be able to write/read data to/from those files. Can anyone show me a way to do this? Does Android's openFileOutput() work in glass?

推荐答案

(在情况下,如果任何人有同样的问题)

(In case if anyone else has the same question)

好吧,我想出了一个办法做到这一点。它看起来像Java I / O库正常工作与Android和也为玻璃。下面玻璃工作正常。

Okay I figured out a way to do this. It looks like Java i/o libraries works fine with android and also for glass. The following works fine in glass.

字符串文件名=sensorData;            FileOutputStream中的OutputStream;

String filename = "sensorData"; FileOutputStream outputStream;

try { outputStream = openFileOutput(filename, Context.MODE_APPEND); OutputStreamWriter outputStreamWriter = new OutputStreamWriter (outputStream); outputStreamWriter.write(content); outputStreamWriter.close(); } catch (Exception e) { e.printStackTrace(); } //Printing the file in logcat just to verify the contents FileInputStream inputStream; try { inputStream = openFileInput(filename); InputStreamReader inputStreamReader = new InputStreamReader (inputStream); char[] buffer = new char[content.length()]; inputStreamReader.read(buffer); String input = buffer.toString(); Log.i(input); } catch (Exception e) { e.printStackTrace(); }

更多推荐

如何创建从谷歌玻璃应用程序的文件?

本文发布于:2023-11-11 05:58:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   玻璃   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!