问题节省了摩托罗拉Droid的文件,Android 2.1的? [英] Problem saving file on Motorola Droid, Android 2.1?

查看:111
本文介绍了问题节省了摩托罗拉Droid的文件,Android 2.1的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的两个用户都报告了我的Andr​​oid应用程序,OftSeen手势的一个问题。他们都使用的是摩托罗拉Droid。该应用程序可以节省这是姿态姓名和电话号码,两个字符串只是一个列表的文本文件。它并将文件保存到专用数据区。我不知道这是这个code,它是失败的,但他们报告的分配数字消失了电话出来屏的睡眠之后。由于该文件是重读的OnCreate每一次,我假设该文件不归还存在。

Two of my users have reported a problem with my Android application, OftSeen Gestures. Both of them are using a Motorola Droid. The app saves a text file which is just a list of gesture names and phone numbers, both strings. It saves the file to the private data area. I don't know that it is this code that is failing but they report the assigned numbers disappearing after the phone comes out of screen sleep. Since the file is reread in OnCreate each time, I'm assuming the file doesn't exist on return.

只要我能得到我的手在我的Droid将调试,但在此期间,你可以看到一个原因,这个保存操作上的Droid将失败(没有其他用户已经报告了这一点)?

As soon as I can get my hands on a Droid I will debug it but in the meantime can you see a reason why this save operation would fail on Droid (no other users have reported this)?

    OutputStreamWriter out = new OutputStreamWriter(AppGlobal.getContext().openFileOutput(MAPPINGS_FILE_NAME, 0));

    for (String key : mMap.keySet()) {
        String number = mMap.get(key).number;
        out.write(String.format("%s,%s\n", key, number == null ? "" : number));
    }
    out.close();

AppGlobal.getContext返回应用程序上下文和MAPPINGS_FILE_NAME解析为gesture_mappings.txt。

AppGlobal.getContext returns the application context and the MAPPINGS_FILE_NAME resolves to "gesture_mappings.txt".

就像我说的,我不知道,这就是问题所在。这可能是别的事情做与内部应用程序状态管理。如果任何人有Droid的,也许他们可以从市场下载的应用程序,并测试一下吗?请注意,这是一个真正的帮助请求 - 不是为了增加我的下载

Like I say, I don't know that this is the problem. It could be something else to do with state management inside the app. If anyone has a Droid, maybe they could download the app from Market and test it for me? Note this is a genuine request for help - not an attempt to increase my downloads.

推荐答案

这被诊断为可能出自扩展字符集导致换行符是misinter preTED并解决了明确写入使用UTF8文件。请参阅<一href="http://stackoverflow.com/questions/2735323/how-to-read-and-write-utf-8-to-disk-on-the-android">How读写UTF-8到磁盘上的Andr​​oid? <一个href="http://stackoverflow.com/questions/2735323/how-to-read-and-write-utf-8-to-disk-on-the-android">1

This was diagnosed as being caused by extended character sets causing line-breaks to be misinterpreted and was solved by explicitly writing the file using UTF8. See How to read and write UTF-8 to disk on the Android? 1

这篇关于问题节省了摩托罗拉Droid的文件,Android 2.1的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆