[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread murphy

Thanks for the explanation. I found the files there alright so the
code is working which is great. Now I need to access the files in the
device to display their contents in a TextView in a screen. I've been
trying to do something like this:

String text = new String(istr);
TextView tv = (TextView)findViewById(R.id.somenews);
tv.setText(text);
setContentView(R.layout.latestnews);

but I'm not really sure how to do it.



On Mar 22, 2:22 am, Mark Murphy mmur...@commonsware.com wrote:
 murphy wrote:
  Okay, I went to the Device's menu

 Sorry. Back up.

 You said you use Eclipse.

 Eclipse, with the Android plugin, has a perspective called DDMS. If you
 cannot find it, run the ddms program from the tools/ folder in your SDK,
 then select your running emulator in the table on the left.

 In either the perspective or the standalone tool, there should be a menu
 choice called File Explorer. Choose it.

 That will bring up a tree showing the contents of the filesystems on
 your running emulator. In there, browse to
 /data/data/whatever.you.elected.to.call.your.package/files, and you will
 (hopefully) see your files.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread Mark Murphy

murphy wrote:
 Thanks for the explanation. I found the files there alright so the
 code is working which is great. Now I need to access the files in the
 device to display their contents in a TextView in a screen. I've been
 trying to do something like this:
 
   String text = new String(istr);
   TextView tv = (TextView)findViewById(R.id.somenews);
 tv.setText(text);
 setContentView(R.layout.latestnews);
 
 but I'm not really sure how to do it.

setContentView() has to be called before findViewById(), assuming the
layout you define in setContentView() has the widgets you're trying to
access in findViewById().

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread murphy

I'm using the code in this fashion:

try{



URL myURL = new URL(http://www.indulec.ie/weather.txt;);

URLConnection conn = myURL.openConnection();
conn.connect();

BufferedReader is = new BufferedReader(new InputStreamReader
(conn.getInputStream(), UTF-8));

FileOutputStream fOut = openFileOutput(news.txt,
MODE_WORLD_READABLE);

OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF-8);

String istr;

while ((istr = is.readLine()) != null)
osw.write(istr+\n);
osw.close();

setContentView(R.layout.latestnews);
String text = new String(istr);
TextView tv = (TextView)findViewById(R.id.somenews);
tv.setText(text);
}
catch ( IOException e )
{
Log.d(TAG, Can not connect to the target server! );
try {
throw new IOException();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}


but I'm just getting an error saying the app has stopped unexpectedly.
The whole setContentView() bit is wrong but i'm just not sure how to
access the news.txt file once it has been saved in the devices data
files.


On Mar 22, 1:39 pm, Mark Murphy mmur...@commonsware.com wrote:
 murphy wrote:
  Thanks for the explanation. I found the files there alright so the
  code is working which is great. Now I need to access the files in the
  device to display their contents in a TextView in a screen. I've been
  trying to do something like this:

                     String text = new String(istr);
                     TextView tv = (TextView)findViewById(R.id.somenews);
              tv.setText(text);
              setContentView(R.layout.latestnews);

  but I'm not really sure how to do it.

 setContentView() has to be called before findViewById(), assuming the
 layout you define in setContentView() has the widgets you're trying to
 access in findViewById().

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread murphy

I've added in also the line FileInputStream fIn = openFileInput
(news.txt); but I don't know what to do with it once I open it to be
able to display it in my TextView in a new screen.


On Mar 22, 3:59 pm, murphy howt...@hotmail.com wrote:
 I'm using the code in this fashion:

 try{

                 URL myURL = new URL(http://www.indulec.ie/weather.txt;);

                 URLConnection conn = myURL.openConnection();
                 conn.connect();

                 BufferedReader is = new BufferedReader(new InputStreamReader
 (conn.getInputStream(), UTF-8));

                 FileOutputStream fOut = openFileOutput(news.txt,
 MODE_WORLD_READABLE);

                 OutputStreamWriter osw = new OutputStreamWriter(fOut, 
 UTF-8);

                 String istr;

                 while ((istr = is.readLine()) != null)
                         osw.write(istr+\n);
                 osw.close();

                 setContentView(R.layout.latestnews);
                 String text = new String(istr);
                 TextView tv = (TextView)findViewById(R.id.somenews);
             tv.setText(text);
                 }
                 catch ( IOException e )
             {
                 Log.d(TAG, Can not connect to the target server! );
                 try {
                                         throw new IOException();
                                 } catch (IOException e1) {
                                         // TODO Auto-generated catch block
                                         e1.printStackTrace();
                                 }
             }

 but I'm just getting an error saying the app has stopped unexpectedly.
 The whole setContentView() bit is wrong but i'm just not sure how to
 access the news.txt file once it has been saved in the devicesdata
 files.

 On Mar 22, 1:39 pm, Mark Murphy mmur...@commonsware.com wrote:

  murphy wrote:
   Thanks for the explanation. I found the files there alright so the
   code is working which is great. Now I need to access the files in the
   device to display their contents in a TextView in a screen. I've been
   trying to do something like this:

                      String text = new String(istr);
                      TextView tv = (TextView)findViewById(R.id.somenews);
               tv.setText(text);
               setContentView(R.layout.latestnews);

   but I'm not really sure how to do it.

  setContentView() has to be called before findViewById(), assuming the
  layout you define in setContentView() has the widgets you're trying to
  access in findViewById().

  --
  Mark Murphy (a Commons Guy)http://commonsware.com
  _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread Mark Murphy

murphy wrote:
 I've added in also the line FileInputStream fIn = openFileInput
 (news.txt); but I don't know what to do with it once I open it to be
 able to display it in my TextView in a new screen.

http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: Three Android Books, Plus Updates, $35/Year

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-22 Thread murphy

I've got it working now, I used this code to finish it:

FileInputStream fIn = openFileInput(news.txt);
InputStreamReader isr = null;
char[] inputBuffer = new char[255];
String data = null;

try{
  isr = new InputStreamReader(fIn);
  isr.read(inputBuffer);
  data = new String(inputBuffer);
  Toast.makeText(getBaseContext(), Settings
read,Toast.LENGTH_SHORT).show();
  }
  catch (Exception e) {
  e.printStackTrace();
  Toast.makeText(getBaseContext(), Settings not
read,Toast.LENGTH_SHORT).show();
  }
  finally {
 try {
isr.close();
fIn.close();
} catch (IOException e) {
e.printStackTrace();
}
  }
  setContentView(R.layout.latestnews);
  TextView tv = (TextView)findViewById(R.id.somenews);
  tv.setText(data);

Thanks very much for all your help. It is much appreciated.



On Mar 22, 4:23 pm, Mark Murphy mmur...@commonsware.com wrote:
 murphy wrote:
  I've added in also the line FileInputStream fIn = openFileInput
  (news.txt); but I don't know what to do with it once I open it to be
  able to display it in my TextView in a new screen.

 http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 Warescription: Three Android Books, Plus Updates, $35/Year
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Simon Depiets

Hi, you should try something like

URL myURL = new URL(http://lol.com/lol.txt;);
URLConnection conn = myURL.openConnection();
conn.connect();
BufferedReader is = new BufferedReader(new InputStreamReader
(conn.getInputStream(), UTF8));
FileOutputStream fOut = openFileOutput(lol.txt, MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF8);
String istr;
while ((istr = is.readLine()) != null)
osw.write(istr+\n);
osw.close();


This download the http://lol.comlol.txt file to lol.txt local file
Also check the DDMS LogCat tab for where  your error is.
2009/3/21 murphy howt...@hotmail.com:

 Hi all, I am having difficulty retrieving data from the internet to be
 displayed in a TextView. When I run the application it says the
 application has stopped unexpectedly. I am using the code:

 String urls = http://www.indulec.ie/weather.txt;;

            HttpClient client = new DefaultHttpClient();

            // Create a method instance.
            HttpGet method = new HttpGet(urls);
            method.getParams().setIntParameter
 (CoreConnectionPNames.CONNECTION_TIMEOUT, 1 );
            method.getParams().setIntParameter
 (CoreConnectionPNames.SO_TIMEOUT, 1 );
            method.getParams().setIntParameter
 (CoreConnectionPNames.SOCKET_BUFFER_SIZE, 20 );
            method.getParams().setIntParameter
 (ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 );
            method.getParams().setIntParameter
 (ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 );

            HttpResponse response = null;
            InputStream input = null;

            try
            {
                response = client.execute( method );
                HttpEntity entity = response.getEntity();
                input = entity.getContent();



                TextView tv = (TextView)findViewById(R.id.somenews);
                tv.setText((CharSequence) input);

                setContentView(R.layout.latestnews);


            }
            catch ( IOException e )
            {
                Log.d(, Can not connect to the target server! );
                try {
                                        throw new IOException();
                                } catch (IOException e1) {
                                        // TODO Auto-generated catch block
                                        e1.printStackTrace();
                                }
            }
            finally
            {
                Log.d(, close Expired Connections! );
                client.getConnectionManager().closeExpiredConnections
 ();
            }

 




-- 
Lliane aka Simon Depiets
Epita Promo 2011,42
http://www.lliane.com
A man is smoking with his girlfriend. She angers herself : don't you
see the warning on the box ?!
To which the man replies, I am a programmer. I don't worry about
warnings. I only worry about errors.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Streets Of Boston

Your use of HttpGet is good.
However, you cast an InputStream to a char-sequence when calling
tv.setText((CharSequence)input);.
This will give you a class-cast exception. Read char-data from the
InputStream instead.

Also, try to find out if 'entity' has some methods to get a String
back that has the content of the HttpResponse. Then you can skip
handling the InputStream and reading a string from it.


Also, did you give your app internet-permission?

On Mar 21, 5:10 pm, murphy howt...@hotmail.com wrote:
 Hi all, I am having difficulty retrieving data from the internet to be
 displayed in a TextView. When I run the application it says the
 application has stopped unexpectedly. I am using the code:

 String urls = http://www.indulec.ie/weather.txt;;

             HttpClient client = new DefaultHttpClient();

             // Create a method instance.
             HttpGet method = new HttpGet(urls);
             method.getParams().setIntParameter
 (CoreConnectionPNames.CONNECTION_TIMEOUT, 1 );
             method.getParams().setIntParameter
 (CoreConnectionPNames.SO_TIMEOUT, 1 );
             method.getParams().setIntParameter
 (CoreConnectionPNames.SOCKET_BUFFER_SIZE, 20 );
             method.getParams().setIntParameter
 (ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 );
             method.getParams().setIntParameter
 (ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 );

             HttpResponse response = null;
             InputStream input = null;

             try
             {
                 response = client.execute( method );
                 HttpEntity entity = response.getEntity();
                 input = entity.getContent();

                 TextView tv = (TextView)findViewById(R.id.somenews);
                 tv.setText((CharSequence) input);

                 setContentView(R.layout.latestnews);

             }
             catch ( IOException e )
             {
                 Log.d(, Can not connect to the target server! );
                 try {
                                         throw new IOException();
                                 } catch (IOException e1) {
                                         // TODO Auto-generated catch block
                                         e1.printStackTrace();
                                 }
             }
             finally
             {
                 Log.d(, close Expired Connections! );
                 client.getConnectionManager().closeExpiredConnections
 ();
             }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread murphy

Hi, I used the code you suggested Simon in this way,

try{

URL myURL = new URL(http://www.indulec.ie/weather.txt;);

URLConnection conn = myURL.openConnection();
conn.connect();

BufferedReader is = new BufferedReader(new InputStreamReader
(conn.getInputStream(), UTF8));

FileOutputStream fOut = openFileOutput(news.txt,
MODE_WORLD_READABLE);

OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF8);

String istr;

while ((istr = is.readLine()) != null)
osw.write(istr+\n);
osw.close();
}
catch (IOException e) {
throw new RuntimeException(e);

}

but it doesn't seem to be editing my news.txt file. I have it saved in
the assets folder of my application. Is this correct?

I have uses-permission android:name=android.permission.INTERNET/
uses-permission included in my Manifest, this just has to be
physically typed in right? I don't need to add it in some way.

Thanks very much for any help you can give.



On Mar 21, 9:20 pm, Simon Depiets sdepi...@gmail.com wrote:
 Hi, you should try something like

 URL myURL = new URL(http://lol.com/lol.txt;);
 URLConnection conn = myURL.openConnection();
 conn.connect();
 BufferedReader is = new BufferedReader(new InputStreamReader
                             (conn.getInputStream(), UTF8));
 FileOutputStream fOut = openFileOutput(lol.txt, MODE_WORLD_READABLE);
 OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF8);
 String istr;
 while ((istr = is.readLine()) != null)
 osw.write(istr+\n);
 osw.close();

 This download thehttp://lol.comlol.txtfile to lol.txt local file
 Also check the DDMS LogCat tab for where  your error is.
 2009/3/21 murphy howt...@hotmail.com:





  Hi all, I am having difficulty retrieving data from the internet to be
  displayed in a TextView. When I run the application it says the
  application has stopped unexpectedly. I am using the code:

  String urls = http://www.indulec.ie/weather.txt;;

             HttpClient client = new DefaultHttpClient();

             // Create a method instance.
             HttpGet method = new HttpGet(urls);
             method.getParams().setIntParameter
  (CoreConnectionPNames.CONNECTION_TIMEOUT, 1 );
             method.getParams().setIntParameter
  (CoreConnectionPNames.SO_TIMEOUT, 1 );
             method.getParams().setIntParameter
  (CoreConnectionPNames.SOCKET_BUFFER_SIZE, 20 );
             method.getParams().setIntParameter
  (ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 );
             method.getParams().setIntParameter
  (ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 );

             HttpResponse response = null;
             InputStream input = null;

             try
             {
                 response = client.execute( method );
                 HttpEntity entity = response.getEntity();
                 input = entity.getContent();

                 TextView tv = (TextView)findViewById(R.id.somenews);
                 tv.setText((CharSequence) input);

                 setContentView(R.layout.latestnews);

             }
             catch ( IOException e )
             {
                 Log.d(, Can not connect to the target server! );
                 try {
                                         throw new IOException();
                                 } catch (IOException e1) {
                                         // TODO Auto-generated catch block
                                         e1.printStackTrace();
                                 }
             }
             finally
             {
                 Log.d(, close Expired Connections! );
                 client.getConnectionManager().closeExpiredConnections
  ();
             }

 --
 Lliane aka Simon Depiets
 Epita Promo 2011,42http://www.lliane.com
 A man is smoking with his girlfriend. She angers herself : don't you
 see the warning on the box ?!
 To which the man replies, I am a programmer. I don't worry about
 warnings. I only worry about errors.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Mark Murphy



 Hi, I used the code you suggested Simon in this way,

 try{

   URL myURL = new URL(http://www.indulec.ie/weather.txt;);

   URLConnection conn = myURL.openConnection();
   conn.connect();

   BufferedReader is = new BufferedReader(new InputStreamReader
 (conn.getInputStream(), UTF8));

   FileOutputStream fOut = openFileOutput(news.txt,
 MODE_WORLD_READABLE);

   OutputStreamWriter osw = new OutputStreamWriter(fOut, UTF8);

   String istr;

   while ((istr = is.readLine()) != null)
   osw.write(istr+\n);
   osw.close();
   }
   catch (IOException e) {
 throw new RuntimeException(e);

 }

 but it doesn't seem to be editing my news.txt file. I have it saved in
 the assets folder of my application. Is this correct?

You are attempting to download news.txt. Given your code, when downloaded,
that file will appear in:

/data/data/your.package.here/files

 I have uses-permission android:name=android.permission.INTERNET/
 uses-permission included in my Manifest, this just has to be
 physically typed in right? I don't need to add it in some way.

No, but it might be in the wrong spot. If you could, post both your
AndroidManifest.xml that you are using with the above code and the actual
Java error you are receiving (via adb logcat, DDMS, the DDMS perspective
in Eclipse).

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread murphy

I'm not receiving any error. Its just that when I click the button in
my application which should call a function to go online and download
data to the news.txt file, nothing happens.

My Manifest reads as follows:

?xml version=1.0 encoding=utf-8?
manifest xmlns:android=http://schemas.android.com/apk/res/android;
  package=com.organiser.college
  android:versionCode=1
  android:versionName=1.0.0
  uses-permission android:name=android.permission.INTERNET/
uses-permission
application android:icon=@drawable/icon android:label=@string/
app_name
activity android:name=.CollegeOrganiser
android:label=@string/app_name
intent-filter
action android:name=android.intent.action.MAIN /
category
android:name=android.intent.category.LAUNCHER /
/intent-filter
/activity
/application


/manifest



On Mar 21, 11:29 pm, Mark Murphy mmur...@commonsware.com wrote:
  Hi, I used the code you suggested Simon in this way,

  try{

                     URL myURL = new URL(http://www.indulec.ie/weather.txt;);

                     URLConnection conn = myURL.openConnection();
                     conn.connect();

                     BufferedReader is = new BufferedReader(new 
  InputStreamReader
  (conn.getInputStream(), UTF8));

                     FileOutputStream fOut = openFileOutput(news.txt,
  MODE_WORLD_READABLE);

                     OutputStreamWriter osw = new OutputStreamWriter(fOut, 
  UTF8);

                     String istr;

                     while ((istr = is.readLine()) != null)
                     osw.write(istr+\n);
                     osw.close();
                     }
                     catch (IOException e) {
                  throw new RuntimeException(e);

          }

  but it doesn't seem to be editing my news.txt file. I have it saved in
  the assets folder of my application. Is this correct?

 You are attempting to download news.txt. Given your code, when downloaded,
 that file will appear in:

 /data/data/your.package.here/files

  I have uses-permission android:name=android.permission.INTERNET/
  uses-permission included in my Manifest, this just has to be
  physically typed in right? I don't need to add it in some way.

 No, but it might be in the wrong spot. If you could, post both your
 AndroidManifest.xml that you are using with the above code and the actual
 Java error you are receiving (via adb logcat, DDMS, the DDMS perspective
 in Eclipse).

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Mark Murphy

 I'm not receiving any error.

Ah, sorry. I was sifting through earlier messages in the thread and
thought you were getting an error.

 Its just that when I click the button in
 my application which should call a function to go online and download
 data to the news.txt file, nothing happens.

The manifest looks OK.

You use UTF8 instead of UTF-8 in your streams, and I think the latter
is the correct value there.

If it helps, here is a slight variation of your algorithm, at least on the
reading side:

http://www.exampledepot.com/egs/java.net/ReadFromURL.html

Do you have any evidence that the code is executing (e.g., stepping
through it in Eclipse, sprinkling in Log.d statements)?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Simon Depiets

2009/3/22 Mark Murphy mmur...@commonsware.com:

 I'm not receiving any error.

 Ah, sorry. I was sifting through earlier messages in the thread and
 thought you were getting an error.

 Its just that when I click the button in
 my application which should call a function to go online and download
 data to the news.txt file, nothing happens.

 The manifest looks OK.

 You use UTF8 instead of UTF-8 in your streams, and I think the latter
 is the correct value there.

UTF-8 and UTF8 are aliased so both of them are ok. And as Mark said
your file will be written in
/data/data/your.package.here/files

-- 
Lliane aka Simon Depiets
Epita Promo 2011,42
http://www.lliane.com
A man is smoking with his girlfriend. She angers herself : don't you
see the warning on the box ?!
To which the man replies, I am a programmer. I don't worry about
warnings. I only worry about errors.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread murphy

I can't find /data/data/my.package.here/files. I don't seem to have a
data folder.



On Mar 22, 12:42 am, Simon Depiets sdepi...@gmail.com wrote:
 2009/3/22 Mark Murphy mmur...@commonsware.com:



  I'm not receiving any error.

  Ah, sorry. I was sifting through earlier messages in the thread and
  thought you were getting an error.

  Its just that when I click the button in
  my application which should call a function to go online and download
 datato the news.txt file, nothing happens.

  The manifest looks OK.

  You use UTF8 instead of UTF-8 in your streams, and I think the latter
  is the correct value there.

 UTF-8 and UTF8 are aliased so both of them are ok. And as Mark said
 your file will be written in
 /data/data/your.package.here/files

 --
 Lliane aka Simon Depiets
 Epita Promo 2011,42http://www.lliane.com
 A man is smoking with his girlfriend. She angers herself : don't you
 see the warning on the box ?!
 To which the man replies, I am a programmer. I don't worry about
 warnings. I only worry about errors.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Mark Murphy

 I can't find /data/data/my.package.here/files. I don't seem to have a
 data folder.

Are you working on the emulator, or the device?

If it's the device, you probably cannot browse to the location using DDMS
due to security restrictions. However, you should be able to use adb pull
to pull the file given the full path, IIRC.

The emulator, though, should let you browse to your package (whatever the
name is, shown above as my.package.here) and its contents.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Simon Depiets

2009/3/22 Mark Murphy mmur...@commonsware.com:

 I can't find /data/data/my.package.here/files. I don't seem to have a
 data folder.

 Are you working on the emulator, or the device?
Be sure you look in the InternalMemory, not the SDCard aswell


-- 
Lliane aka Simon Depiets
Epita Promo 2011,42
http://www.lliane.com
A man is smoking with his girlfriend. She angers herself : don't you
see the warning on the box ?!
To which the man replies, I am a programmer. I don't worry about
warnings. I only worry about errors.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread murphy

I'm working on the emulator using eclipse. I have a workspace for the
project on my desktop. When I go into my application's folder my
options are other folders like .setting, assets, res, bin and src. I
don't know where to go to find the news.txt file.



On Mar 22, 12:56 am, Mark Murphy mmur...@commonsware.com wrote:
  I can't find /data/data/my.package.here/files. I don't seem to have a
 datafolder.

 Are you working on the emulator, or the device?

 If it's the device, you probably cannot browse to the location using DDMS
 due to security restrictions. However, you should be able to use adb pull
 to pull the file given the full path, IIRC.

 The emulator, though, should let you browse to your package (whatever the
 name is, shown above as my.package.here) and its contents.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Mark Murphy

 I'm working on the emulator using eclipse. I have a workspace for the
 project on my desktop. When I go into my application's folder my
 options are other folders like .setting, assets, res, bin and src. I
 don't know where to go to find the news.txt file.

Ah!

You're looking in your project, not in the device.

Go to the DDMS perspective, and you should find a menu choice(?) for
browsing the file system of the running emulator. In the standalone DDMS,
it's a File Explorer menu choice.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread murphy

Okay, I went to the Device's menu, selected Dev Tools, then went to
Package Browser and found my package, selected it and was then brought
to a screen displaying details. Under Data is written /data/data/
my.package.name. Don't know what any of it means. Couldn't see any
sign of the text file. Sorry for being so bad at this. Only been
really getting into Android recently.



On Mar 22, 1:11 am, Mark Murphy mmur...@commonsware.com wrote:
  I'm working on the emulator using eclipse. I have a workspace for the
  project on my desktop. When I go into my application's folder my
  options are other folders like .setting, assets, res, bin and src. I
  don't know where to go to find the news.txt file.

 Ah!

 You're looking in your project, not in the device.

 Go to the DDMS perspective, and you should find a menu choice(?) for
 browsing the file system of the running emulator. In the standalone DDMS,
 it's a File Explorer menu choice.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Retreivng data from internet source.

2009-03-21 Thread Mark Murphy

murphy wrote:
 Okay, I went to the Device's menu

Sorry. Back up.

You said you use Eclipse.

Eclipse, with the Android plugin, has a perspective called DDMS. If you
cannot find it, run the ddms program from the tools/ folder in your SDK,
then select your running emulator in the table on the left.

In either the perspective or the standalone tool, there should be a menu
choice called File Explorer. Choose it.

That will bring up a tree showing the contents of the filesystems on
your running emulator. In there, browse to
/data/data/whatever.you.elected.to.call.your.package/files, and you will
(hopefully) see your files.


-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---