Может кто-нибудь сказать мне, что не так с моим кодом ниже?
Я новичок в Java и Android Dev, большое спасибо в продвинутом! :)
public class GetContentThenAppend extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv2;
tv2 = (TextView) this.findViewById(R.id.thetext);
tv2.setText("This is the writing program...\n");
try{
/*
File f = new File(Environment.getExternalStorageDirectory()+"/EngagiaDroid/videos.html");
FileInputStream fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String();
//just reading each line and pass it on the debugger
int x = 1;
while((readString = buf.readLine())!= null){
tv2.append( Integer.toString(x) + ":> " );
tv2.append( readString );
tv2.append( "\n" );
x++;
}
*/
final String entryString = new String("" +
"<div stle='color: red; border: this solid red;'>" +
"Hey yo this is the new content!!!" +
"</div>" +
"</div>" +
"</div>" +
"</body>" +
"</html>");
String htmlFile = Environment.getExternalStorageDirectory()+"/EngagiaDroid/videos.html";
FileOutputStream fOut = openFileOutput(htmlFile, MODE_APPEND);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(entryString);
osw.flush();
osw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}
}
Я пытаюсь обновить содержимое html, добавив к нему какой-либо строковый / html-код. я получаю сообщение о принудительном закрытии, когда пытаюсь его запустить.