Android Open Source - voc Save Q R File






From Project

Back to project page voc.

License

The source code is released under:

GNU General Public License

If you think the Android project voc 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 cleanup;
/* ww w .  j a  va  2 s  . com*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;

public class SaveQRFile {

  private static String tag = "saveFile";

  /**
   * Saves QR code string in order to get it later.
   */
  public static void saveQRcode(Context ctx, String qrcode) {
    PrintWriter mCurrentFile = null;
    try {
      File folder = new File(Environment.getExternalStorageDirectory()
          + "/BreezingData");
      if (!folder.exists()) {
        folder.mkdir();
      }
      String qrcodeFile = folder + "/" + "QRcode.txt";
      File outputFile = new File(qrcodeFile);
      if (!outputFile.exists()) {
        outputFile.createNewFile();
      }
      mCurrentFile = new PrintWriter(new FileOutputStream(outputFile));

      // Tell the media scanner about the new file so that it is
      // immediately available to the user.
      MediaScannerConnection.scanFile(ctx,
          new String[] { outputFile.toString() }, null,
          new MediaScannerConnection.OnScanCompletedListener() {
            public void onScanCompleted(String path, Uri uri) {
              Log.i("ExternalStorage", "Scanned " + path + ":");
              Log.i("ExternalStorage", "-> uri=" + uri);
            }
          });
    }
    catch (Exception e) {
      Log.d(tag, "Caught exception mCurrentFile" + e);
    }

    try {
      StringBuffer buff = new StringBuffer();
      buff.append(qrcode);
      mCurrentFile.println(buff.toString());
      buff.delete(0, buff.length());
      mCurrentFile.flush();
    }
    catch (Exception e) {
      Log.d(tag, "Caught Exception in save data into QRcode" + e);
    }
  }
}




Java Source Code List

cleanup.DrawGraph.java
cleanup.Instructions.java
cleanup.PositionService.java
cleanup.QRcodeFromFile.java
cleanup.QRcodeParse.java
cleanup.SaveQRFile.java
display.DynamicPlotDataSource.java
display.DynamicPlotSeries.java
processing.LinearRegression.java
processing.SensorCurve.java
transmission.BluetoothChatService.java
transmission.LocalProfile.java
transmission.thirdlib.capture.CaptureActivityHandler.java
transmission.thirdlib.capture.CaptureActivity.java
transmission.thirdlib.capture.DecodeFormatManager.java
transmission.thirdlib.capture.DecodeHandler.java
transmission.thirdlib.capture.DecodeThread.java
transmission.thirdlib.capture.FinishListener.java
transmission.thirdlib.capture.InactivityTimer.java
transmission.thirdlib.capture.IntentSource.java
transmission.thirdlib.capture.Intents.java
transmission.thirdlib.capture.PlanarYUVLuminanceSource.java
transmission.thirdlib.capture.PreferencesActivity.java
transmission.thirdlib.capture.ViewfinderResultPointCallback.java
transmission.thirdlib.capture.ViewfinderView.java
transmission.thirdlib.manager.AutoFocusCallback.java
transmission.thirdlib.manager.CameraConfigurationManager.java
transmission.thirdlib.manager.CameraManager.java
transmission.thirdlib.manager.PreviewCallback.java
userinterface.BluetoothViewer.java
userinterface.ConfigActivity.java
userinterface.DeviceListActivity.java
userinterface.GuideActivity.java
userinterface.HistoryActivity.java
userinterface.SlidingDrawerActivity.java
userinterface.Welcome.java