Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Files not created on SD card

Files not created on SD card

Put your problem here if it does not fit any of the other categories.

Files not created on SD card

Postby briandanielsen » Fri Apr 30, 2010 11:02 pm

Hello,

I cannot figure out why the files I create in my application does not allways get written to the SD card.
My manifest contains WRITE_EXTERNAL_STORAGE, so that is not the problem.

The code is running in a thread and gets input from a queue. The file does get created.

Have any of you been experienced something similar?

My sourcecode:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import java.io.BufferedWriter;
  3.  
  4. import java.io.File;
  5.  
  6. import java.io.FileWriter;
  7.  
  8. import java.io.IOException;
  9.  
  10. import java.util.Date;
  11.  
  12. import java.util.concurrent.BlockingQueue;
  13.  
  14.  
  15.  
  16. import android.os.Environment;
  17.  
  18. import android.os.Handler;
  19.  
  20. import android.util.Log;
  21.  
  22.  
  23.  
  24. public class LogService {
  25.  
  26.        
  27.  
  28.     // Debugging
  29.  
  30.     private static final String TAG = "LogService";
  31.  
  32.     private static final boolean D = true;
  33.  
  34.        
  35.  
  36.     private BlockingQueue<int[]> mSource = null;
  37.  
  38.     private LogThread mLogThread = null;;
  39.  
  40.     private File mDataFile = null;
  41.  
  42.     private BufferedWriter mBufferedWriter = null;
  43.  
  44.     private FileWriter mFileWriter = null;
  45.  
  46.     private String mPath;
  47.  
  48.    
  49.  
  50.         public LogService(BlockingQueue<int[]> queue, String path) {
  51.  
  52.                 mSource = queue;
  53.  
  54.                 mDataFile = null;
  55.  
  56.                 mPath = path;
  57.  
  58.         }
  59.  
  60.  
  61.  
  62.         public synchronized void start() {
  63.  
  64.                 if(mLogThread == null) {
  65.  
  66.                         mLogThread = new LogThread();
  67.  
  68.                         mLogThread.setName("LogServiceThread");
  69.  
  70.                 }
  71.  
  72.                 mLogThread.start();
  73.  
  74.         }
  75.  
  76.        
  77.  
  78.         public synchronized void stop() {
  79.  
  80.                 if(mLogThread != null) {
  81.  
  82.                         mLogThread.cancel();
  83.  
  84.                         mLogThread = null;
  85.  
  86.                 }
  87.  
  88.         }
  89.  
  90.  
  91.  
  92.         int i = 0;
  93.  
  94.         private class LogThread extends Thread {
  95.  
  96.                
  97.  
  98.                 @Override
  99.  
  100.                 public void run() {
  101.  
  102.                         int[] data = null;
  103.  
  104.                         Date date = new Date();
  105.  
  106.                         long d = date.getTime();
  107.  
  108.                         mDataFile = new File(Environment.getExternalStorageDirectory() + "/" + mPath + String.valueOf(d) + ".txt");
  109.  
  110.                         try {
  111.  
  112.                                 mDataFile.createNewFile();
  113.  
  114.                         } catch (IOException e1) {
  115.  
  116.                                 // TODO Auto-generated catch block
  117.  
  118.                                 e1.printStackTrace();
  119.  
  120.                         }
  121.  
  122.                         while(true){
  123.  
  124.                                 try {
  125.  
  126.                                         Log.i(TAG, String.valueOf(mDataFile.length()));
  127.  
  128.                                         data = mSource.take();
  129.  
  130.                                         mFileWriter = new FileWriter(mDataFile, true);                                 
  131.  
  132.                                         StringBuilder sBuf = new StringBuilder();
  133.  
  134.                                         for (int i = 5; i < data.length; i++) {
  135.  
  136.                                                 //mFileWriter.write(data[i] + "\n");
  137.  
  138.                                                 sBuf.append(data[i] + "\n");
  139.  
  140.                                         }
  141.  
  142.                                         String s = sBuf.toString();
  143.  
  144.                                         mFileWriter.write(s);
  145.  
  146.                                         mFileWriter.close();
  147.  
  148.                                 }
  149.  
  150.                                 catch (InterruptedException e) {
  151.  
  152.                                         e.printStackTrace();
  153.  
  154.                                 } catch (IOException e) {
  155.  
  156.                                         e.printStackTrace();
  157.  
  158.                                 }
  159.  
  160.                         }
  161.  
  162.                 }
  163.  
  164.                
  165.  
  166.                 public void cancel() {
  167.  
  168.                         try {
  169.  
  170.                                 mLogThread.join();
  171.  
  172.                         } catch (InterruptedException e) {
  173.  
  174.                                 Log.e(TAG, e.getMessage());
  175.  
  176.                         }
  177.  
  178.                 }
  179.  
  180.         }
  181.  
  182. }
  183.  
  184.  
Parsed in 0.016 seconds, using GeSHi 1.0.8.4
briandanielsen
Freshman
Freshman
 
Posts: 5
Joined: Sun Nov 22, 2009 5:14 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 11 guests