English 中文(简体)
无法获得纸张
原标题:Unable to access sdcard

I m试图读/篡改纸面。 我在真的电话上和在剪切片上的推器上都尝试这样做。 在这两种装置上,允许使用/mnt/sdcard/或/sdcard只是“d--”,我猜测,我可以读写。

我不得不从ec子中的“File view”中打开手脚,而且当我还尝试“adb 拉/mnt/sdcard/test.txt 测试”时,我也可以开口。 我拿不到遥远物体。

甲状腺 app的确允许“EPAITE_EXTERNAL_STORAGE”。

例如,我管理时所做的事;

        try {
            File root = Environment.getExternalStorageDirectory();
            Log.e(TAG,root.getAbsolutePath());
                File gpxfile = new File(root, "test.txt");
                FileWriter gpxwriter = new FileWriter(gpxfile);
                BufferedWriter out = new BufferedWriter(gpxwriter);
                out.write("Hello world");
                out.close();
        } catch (IOException e) {
            Log.e(TAG, "Could not write file " + e.getMessage());
        }

I do not get an exception. Any ideas? This problem is killing me!

最佳回答

举例来说,你可以展示从 per铁中摄像的图像,从而需要许可。

许可

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Java档案

package com.sdcard;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;

public class SdcardActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try{
            URL url = new URL ("http://www.coolpctips.com/wp-content/uploads/2011/05/top-30-android-games.jpg");
            InputStream input = url.openStream();
            try {
                OutputStream output = new FileOutputStream  (Environment.getExternalStorageDirectory()+"/top-30-android-games.jpg");
                int aReasonableSize = 1000;
                byte[] buffer = new byte[aReasonableSize];
                int bytesRead = 0;;
                try {
                    while ((bytesRead = input.read(buffer)) > 0) {
                        output.write(buffer, 0, bytesRead);
                    }
                } finally {
                    output.close();
                }
            } finally {
                input.close();
            }
            }catch (Exception e) {
                e.printStackTrace();
            }
        }

www.un.org/Depts/DGACM/index_spanish.htm 一段时间后,我们在互联网连接失灵或无法找到明卡的装置方面也面临问题。

问题回答

暂无回答




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签