writing into local filesystem?

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

writing into local filesystem?

Postby chaoz1336 » Mon Oct 19, 2009 2:44 pm

Hi guys,

I got the prob that I cant write to my local filesystem in Android,
cause I dont have the "permission" for that... even if I know there's no setting in the manifest for that..
I always get "Parent directory of file is not writable: /sdcard/myfile"



my code: (even if I dont think its because of that:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. InputStream oIn = oFile.getAsStream();
  2.         FileOutputStream oOut = null;
  3.         try
  4.         {
  5.             File oNewFile = new File(m_strAbsolutePath +"/"+ oFile.getName());
  6.             oNewFile.createNewFile();
  7.            
  8.             oOut = new FileOutputStream(oNewFile);
  9.             return new StreamCopier().copy(oIn, oOut) == oFile.getSize(); //copy inputstream into outputstream
  10.         }
  11.         catch (...)
  12.         {
  13.        ...
  14.         }
  15.         finally
  16.         {
  17.             try
  18.             {
  19.                 if(oOut != null)
  20.                     oOut.close();
  21.             }
  22.             catch (IOException e)
  23.             {
  24.                 e.printStackTrace();
  25.             }
  26.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Top

Postby padde » Mon Oct 19, 2009 4:49 pm

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby chaoz1336 » Tue Oct 20, 2009 9:51 am

padde wrote:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  2.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


as I said:
there is no permission setting for that in the manifest...
I applied your permission, but the error still occours =/

anyone else?
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Postby padde » Tue Oct 20, 2009 10:06 am

Well.. i had the same problem and i needed to add this permission.. but i develop for 1.6.. so maybe this is new to donut.

If we are talking about a sd in the emulator try building a new sd.. i red several times about that and this
was one fix that was suggested. Additionally you could check the sd file on your harddrive if its not read only.

If this all does not help i am at my wits' end.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Steph » Tue Nov 17, 2009 9:12 pm

Me i store my file in /data/data/android.com.us/files/my.xml

I have an exception : File /data/data/android.com.us/files/my.xml contains a path separator null

please help. I tried all the way :'(


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. FILE_NAMES_PATH= "/data/data/android.com.us/files/my.xml";
  5.  
  6.  
  7.  
  8.     private void loadXmlFile()
  9.  
  10.     {
  11.  
  12.         try
  13.  
  14.         {
  15.  
  16.                 //load xml file
  17.  
  18.                 SAXParserFactory spf = SAXParserFactory.newInstance();
  19.  
  20.                 SAXParser sp = spf.newSAXParser();
  21.  
  22.                 XMLReader xr = sp.getXMLReader();
  23.  
  24.        
  25.  
  26.                 MyLocalHandler myHandler = new MyLocalHandler();
  27.  
  28.                 xr.setContentHandler(myHandler);
  29.  
  30.  
  31.  
  32.                 Log.i("US Finder", "loadxmlfile 1");
  33.  
  34.                 FileInputStream fin= this.openFileInput(FILE_NAMES_PATH);
  35.  
  36.                 Log.i("US Finder", "loadxmlfile 2");
  37.  
  38.                 //xr.parse(new InputSource("file://"+FILE_NAMES_PATH));
  39.  
  40.                 xr.parse(new InputSource(fin));
  41.  
  42.                 //parsed data to the user
  43.  
  44.                 if(myHandler.getParsedData()!=null)
  45.  
  46.                         _seriesName=myHandler.getParsedData();
  47.  
  48.         }
  49.  
  50.         catch (Exception e)
  51.  
  52.         {
  53.  
  54.                 Log.e("US Finder", "Load XmlFile "+e.getMessage()+" "+e.getCause());
  55.  
  56.         }
  57.  
  58.     }
  59.  
  60.  
  61.  
  62.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Steph
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Mon Oct 20, 2008 1:48 pm
Location: France

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests