Below is a sample from one of my class files that I am having problems with. What I really just want to do is to add a button to open a new Intent Activity with ACTION_VIEW to display the text file. This wasn't working inside the OnClickListener:
File file = new File(file://android_assets/browsercode.txt);Intent newintent = new Intent(android.conteent.Intent.ACTION_VIEW);
newintent.setData(file);
startActivity(newintent);
It just gave me an error. So instead i am going to just try to read the file's contents into a string and output it to a TextView. This wasn't working either. If anyone has any suggestion on either way, that would be greatful. I have tried many variations of each and got NOWHERE. I perfer the one above with the button click though.
Thanks in advance for any help.
public
File file = new File(file://android_assets/browsercode.txt);Intent newintent = new Intent(android.conteent.Intent.ACTION_VIEW);
newintent.setData(file);
startActivity(newintent);
It just gave me an error. So instead i am going to just try to read the file's contents into a string and output it to a TextView. This wasn't working either. If anyone has any suggestion on either way, that would be greatful. I have tried many variations of each and got NOWHERE. I perfer the one above with the button click though.
Thanks in advance for any help.
public
class CodeSlider extends Activity {
TextView textcode;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.codeslider);
textcode = (TextView)findViewById(R.id.codetext);
readthefile();
}
privatevoid readthefile() {
// TODO Auto-generated method stub
TextView textcode;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.codeslider);
textcode = (TextView)findViewById(R.id.codetext);
readthefile();
}
privatevoid readthefile() {
// TODO Auto-generated method stub
File file =
new File(file://android_assets/browsercode.txt);
int i=0;
FileReader into = null;
try {into = new FileReader(file); // And a char stream to read it
char[] buffer = newchar[4096]; // Read 4K characters at a time
int len; // How many chars read each time
while ((len = into.read(buffer)) != -1){
String s = new String(buffer, 0, len);
i++;
textcode.append(s);
}
}
catch(IOException e) {
System.out.println("Error");return;
}
}
} int i=0;
FileReader into = null;
try {into = new FileReader(file); // And a char stream to read it
char[] buffer = newchar[4096]; // Read 4K characters at a time
int len; // How many chars read each time
while ((len = into.read(buffer)) != -1){
String s = new String(buffer, 0, len);
i++;
textcode.append(s);
}
}
catch(IOException e) {
System.out.println("Error");return;
}
}