Android Open Source - sensor-supervisor File Helper






From Project

Back to project page sensor-supervisor.

License

The source code is released under:

GNU General Public License

If you think the Android project sensor-supervisor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.thirdi.sensorsupervisor;
/*w w w  .j  av a  2s.  c om*/
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

/**
 * 
 * @author htkibar CHECK LATER, WITH A DARN CABLE.
 */
public class FileHelper {

  public FileHelper() {
    
  }

  public Boolean write(String fname, String fcontent) {
    try {
      String fpath = "/sdcard/" + fname + ".txt";
      File file = new File(fpath);
      // If file does not exists, then create it
      if (!file.exists()) {
        file.createNewFile();
      }
      FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
      BufferedWriter bw = new BufferedWriter(fw);
      bw.write(fcontent);
      bw.close();
      Log.d("Suceess", "Sucess");
      return true;
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }

  public boolean isExtStorageWritable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
      return true;
    }

    return false;
  }

  public boolean isExtStorageReadable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)
        || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
      return true;
    }

    return false;
  }
}




Java Source Code List

com.thirdi.sensorsupervisor.AudioFragment.java
com.thirdi.sensorsupervisor.CameraFragment.java
com.thirdi.sensorsupervisor.CameraPreview.java
com.thirdi.sensorsupervisor.DBContract.java
com.thirdi.sensorsupervisor.DBHelper.java
com.thirdi.sensorsupervisor.DatabaseFragment.java
com.thirdi.sensorsupervisor.FileHelper.java
com.thirdi.sensorsupervisor.GPSFragment.java
com.thirdi.sensorsupervisor.MainActivity.java
com.thirdi.sensorsupervisor.MediaFragment.java
com.thirdi.sensorsupervisor.NavigationDrawerFragment.java
com.thirdi.sensorsupervisor.NetworkFragment.java
com.thirdi.sensorsupervisor.SensorFragment.java
com.thirdi.sensorsupervisor.SettingsFragment.java
com.thirdi.sensorsupervisor.WifiAdapter.java
com.thirdi.sensorsupervisor.maps.java