멍멍이네 블로그

다른 블로그들 참고하는데 안되다가 되는 블로그 발견!

file = File 클래스 변수임(안나와있는데 대충 File클래스 메소드를 사용하길래 해당 자료형의 변수로 선언했더니 잘됨.

참고로 파일에 해당하는 뷰어나 볼 수 있는 프로그램이 있어야됨.

 

  Intent intent = new Intent();
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setAction(android.content.Intent.ACTION_VIEW);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  if (file.getName().endsWith(".pdf")){

 intent.setDataAndType(Uri.fromFile(file), "application/pdf");
  }else if (file.getName().endsWith(".hwp")){
intent.setDataAndType(Uri.fromFile(file), "application/hwp");
  }
  try{
   startActivity(intent);
  }catch(ActivityNotFoundException e){
   util.showLongToast("해당파일을 실항할 수 있는 어플리케이션이 없습니다.\n파일을 열 수 없습니다.");
   e.printStackTrace();
  }

 

pdf = "application/pdf"

jpg 등 = "image/*"

docx = "application/msword"

txt = "text"

pptx = "application/vnd.ms-powerpoint"

hwp = "application/haansofthwp"

mp3 = "audio/*"

mp4 = "video/*"

 

 

...

 

mineType 안헷갈리게 조심!

 

 

출처 : http://ldelight.tistory.com/20

확장자 출처 : http://anditstory.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C%ED%8C%8C%EC%9D%BC-%EC%97%B0%EA%B2%B0-Intent-setDataAndTypeUri-MimeType

프레이섭 vampire

시로코섭 미미는변태

인가..

 

서버가 제대로 기억 안나네..

 

이계 연습쩔 받는데 무큐쓰면서 적 무적기 다걸고, 애초에 연습쩔하는데 파티장이 가만히 서있으라는데 중간중간 무큐기로 적 무적걸어줌 ㅋㅋㅋ(무큐쓰면 무적판정있는애들)

그래놓고 뭐라했더니 다 알고있다네요 ㅋㅋ

알면서 쓰면 .. 일부로 방해한건가 ?

 

연습쩔 받는데 파티장이 가만히 있으라는데 무큐기 계속 쓰니까.. 파티장 짠해서 뭐라고 대신 말해줬더만 자기가 잘한줄 아나봄;; 에휴..

 

기억해놨다가 이런애들이랑은 두번다시 팟안해야지;;

 

지난번에 안그래도 공팟에서 암걸렸는데.. 쩔받는데 빡치네 ㅋㅋㅋ

 

저사람들 아녔으면 굳이 4분클도 아니였는데.. 쩔받는데 4분클 하게 해놓고 뭔 잘난줄아는 두명..

 

 

 


  
        File newxmlfile = new File(Environment.getExternalStorageDirectory()+"/new.xml");
        try{
                newxmlfile.createNewFile();
        }catch(IOException e){
                Log.e("IOException", "exception in createNewFile() method");
        }
        //we have to bind the new file with a FileOutputStream
        FileOutputStream fileos = null;       
        try{
                fileos = new FileOutputStream(newxmlfile);
        }catch(FileNotFoundException e){
                Log.e("FileNotFoundException", "can't create FileOutputStream");
        }
        //we create a XmlSerializer in order to write xml data
        XmlSerializer serializer = Xml.newSerializer();
        try {
                //we set the FileOutputStream as output for the serializer, using UTF-8 encoding
                        serializer.setOutput(fileos, "UTF-8");
                        //Write <?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null)
                        serializer.startDocument(null, Boolean.valueOf(true));
                        //set indentation option
                        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
                        //start a tag called "root"
                        serializer.startTag(null, "root");
                        //i indent code just to have a view similar to xml-tree
                                serializer.startTag(null, "child1");
                                serializer.endTag(null, "child1");
                              
                                serializer.startTag(null, "child2");
                                //set an attribute called "attribute" with a "value" for
                                serializer.attribute(null, "attribute", "value");
                                serializer.endTag(null, "child2");
                      
                                serializer.startTag(null, "child3");
                                //write some text inside
                                serializer.text("some text inside child3");
                                serializer.endTag(null, "child3");
                              
                        serializer.endTag(null, "root");
                        serializer.endDocument();
                        //write xml data into the FileOutputStream
                        serializer.flush();
                        //finally we close the file stream
                        fileos.close();
                      
                } catch (Exception e) {
                        Log.e("Exception","error occurred while creating xml file");
                }

 

 

출처 : http://www.shop-wiz.com/document/android/execise_linkage_web_xml_create