将值保存在文件中 [英] save a value in a file

查看:49
本文介绍了将值保存在文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,简单的问题:如何使用android

hello , simple question : how to save ( register) a value in a file with android

推荐答案

在文件中保存(注册)一个值你好anel91,



您必须使用文件io API [^ 。以下示例应该让您入门。

Hello anel91,

You will have to use file io API's[^]. Following sample should get you started.
private void save(String filename, String data)
{
    try
    {
        FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
        fos.write(data.getBytes());
        fos.close();
        toast("File successfully saved.");
    }
    catch (Exception ex)
    {
        toast("Error saving file: " + ex.getLocalizedMessage());
    }
}



您还可以找到这个 [ ^ ]特别教程非常有用。



问候,


You will also find this[^] particular tutorial very useful.

Regards,


这篇关于将值保存在文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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