2013-07-04 4 views
0

현재 프로젝트에서 내 파일/폴더를 SD 카드에 숨길 필요가 있습니다. ?? 나는 파일/폴더를 숨기고 후가공하는 것이 가능한지 궁금해했다. ?? 난 당신이 갤러리J2ME에서 파일/폴더를 숨김/숨김 해제하는 방법

import javax.microedition.midlet.*; 
import javax.microedition.lcdui.*; 
import javax.microedition.io.file.*; 
import javax.microedition.io.*; 
import java.io.*; 

public class WriteMIDlet extends MIDlet implements CommandListener { 
private TextBox textbox; 
private String photos = "fileconn.dir.photos"; 
private Command saveCommand; 
private Command exitCommand; 
private String path; 

public void startApp() { 
    textbox = new TextBox("WriteMIDlet", "", 1000, TextField.ANY); 
    saveCommand = new Command("Save", Command.SCREEN, 1); 
    exitCommand = new Command("Exit", Command.EXIT, 1); 
    textbox.addCommand(saveCommand); 
    textbox.addCommand(exitCommand); 
    textbox.setCommandListener(this); 
    Display.getDisplay(this).setCurrent(textbox); 
    path = System.getProperty(photos); 
} 

public void pauseApp() { 
} 

public void destroyApp(boolean unconditional) { 
} 

private void saveFile(String path, String name) { 
    try { 
     String url = path + name; 
     String string = textbox.getString(); 
     byte data[] = string.getBytes("UTF-8"); 
     FileConnection fconn = (FileConnection)Connector.open(url, Connector.READ_WRITE); 
     if (!fconn.exists()) { 
      fconn.create(); 
     } 
     OutputStream ops = fconn.openOutputStream(); 
     ops.write(data); 
     ops.close(); 
     fconn.close(); 
    } 
    catch (IOException ioe) { 
     System.out.println("IOException: "+ioe.getMessage()); 
    } 
    catch (SecurityException se) { 
     System.out.println("Security exception:" + se.getMessage()); 
    } 
} 

public void commandAction(Command c, Displayable d) { 
    if (c == saveCommand) saveFile(path, "readme.txt"); 
    if (c == exitCommand) this.notifyDestroyed(); 
}  

} 현명한처럼

아래 이미지에서 텍스트 파일을 만들 수 있습니다 검색에서이있어 우리가 따라 숨기기 취소/숨기기 다음 SD 카드에 폴더를 만들 수있는 방법이 필요하다..?? 또한 숨겨진 폴더를 검색 할 수 있습니까? ?? 설명서에 따라

답변

1

당신은

fconn.setHidden(true); 

하지만를 호출 할 수 있습니다

도와주세요 ... ... : 속성은 실제 파일 시스템 의 파일에 적용됩니다

파일 시스템 및 플랫폼이 지원하는 경우이 메서드를 호출하면 즉시 호출됩니다. 파일 시스템이 숨겨진 특성을 지원하지 않으면이 메서드는 무시되고 isHidden()은 항상 false을 반환합니다.

+0

고마워요.하지만 값을 false로 설정하면 다시 표시되지 않습니다. true로 설정하면 텍스트 파일이 숨겨져 있지만 false로 설정하면 true로 설정할 수 있습니다. 그것을 다시 보아라. .. 당신은 이유를 알고 있냐?? – suja

+0

파일을 숨김으로 설정할 수 있다는 점을 알아두면 좋습니다. 왜 반대 (setHidden (false))가 작동하지 않는지 나는 모른다. :( –

관련 문제