add webview links to favorites -


i developing news app shows on 50 news sites in webview , users can open links , read news. want save news headlines or links , show them in favourite page. , in favourite page can clicked , deleted after reading it.

i worked on thought long press on page write link file , read file , make list of favorites. tested text view , writing file seems ok reading not. codes are:

@override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         view myinflater= inflater.inflate(r.layout.fragment_main, container, false);      textview txtview = (textview) myinflater.findviewbyid(r.id.txtview);     txtview.setonlongclicklistener(new view.onlongclicklistener() {         @override         public boolean onlongclick(view v) {             // todo auto-generated method stub             toast.maketext(getactivity(),                     "you have pressed long :)", toast.length_long).show();              string filename ="favoritessss.txt";             file file = new file(getactivity().getfilesdir(), filename);             file directory = getactivity().getdir("sunshine", context.mode_world_readable);              //string filename = "myfile";             string string = "hello world000000000!"+"\r\n";             fileoutputstream outputstream;              try {                 outputstream = getactivity().openfileoutput(filename, context.mode_world_writeable);                 outputstream.write(string.getbytes());                 outputstream.close();             } catch (exception e) {                 e.printstacktrace();         }         return true;     } });      //find view id    final textview tv = (textview)myinflater.findviewbyid(r.id.text_view);      txtview.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             // todo auto-generated method stub              //find directory sd card using api 

//don't hardcode "/sdcard" file sdcard = getactivity().getfilesdir();

//get text file file file = new file(sdcard,"favoritessss.txt"); string[] text = new string[15]; try { bufferedreader br = new bufferedreader(new filereader(file)); (int j=0; j>15; j++) text[j] = br.readline(); br.close(); } catch (ioexception e) { //you'll need add proper error handling here }

//set text tv.settext(text[0]); toast.maketext(getactivity(), text[0], toast.length_short).show(); } }); return myinflater; }

any comments?


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -