小编use*_*906的帖子

保存到SD卡作为文本文件

   stopWriting = (Button) findViewById(R.id.save);
   stopWriting.setOnClickListener(new OnClickListener() {

       @SuppressLint("SdCardPath")
    public void onClick(View v) {
           // stop recording the sensor data
           try {

               myFile = new File("/sdcard/SensorData/" + txtData.getText() + ".txt");
               myFile.createNewFile();

               sData = new FileOutputStream(myFile);
               myOutWriter = new OutputStreamWriter(sData);
               myBufferedWriter = new BufferedWriter(myOutWriter);
               myPrintWriter = new PrintWriter(myBufferedWriter);

               //if(myFile != null )//stopFlag = mSensorManager.cancelTriggerSensor(null, null);
               Toast.makeText(getBaseContext(), "Done", Toast.LENGTH_SHORT).show();
           } catch (Exception e) {
               Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
           }
       }
   });
Run Code Online (Sandbox Code Playgroud)

我试图将陀螺仪数据保存到txt文件,但它不保存.如果有人发现问题,请帮我纠正.

java android save android-sdcard android-memory

13
推荐指数
2
解决办法
4万
查看次数

标签 统计

android ×1

android-memory ×1

android-sdcard ×1

java ×1

save ×1