moto E2文件访问

来源:互联网 发布:虎牙网络女主播排行榜 编辑:程序博客网 时间:2024/06/05 08:18

折腾了几天终于在moto E2手机上的文件访问成功了,我在j2me中访问手机目录

目录前缀file://        也可以用 file://localhost

主目录/

手机目录 phone/      所以moto机器的文件目录为file:///phone/<directory> 或者file://localhost/phone/<directory>

存储卡目录为file:///sd/<directory>/ (moto E2访问不到存储卡 E8可以)

手机目录中的子目录有:

MyAudio/     

MyDocument/

MyImages/

MyProgram/

MyVideo/

MyVoice/

可以自建目录

public static void creatzhuanji(String name)// 新建新专辑
 {
  try {

   System.out.println("b11");

//  footPath =   file:///phone/
   fc = (FileConnection) Connector.open(footPath + name + "/",Connector.READ_WRITE);
     System.out.println("b2");

   System.out.println(fc.exists());

   if (!fc.exists())
    fc.mkdir();// 创建文件jia

  } catch (IOException ex) {
      //ex.printStackTrace();
  }
 }

删除目录

public static void deletezhuanji(int id)
 {//vector专辑目录下的一个子目录
  String name =(String) vzhuanji.elementAt(id);
  try {

   System.out.println(footPath + name + "/");
   if(name.equals("其它"))
   {
    System.out.println("不能删除");
   }else{
    fdir = (FileConnection) Connector.open(footPath + name + "/",
      Connector.READ_WRITE);
    if (fdir.exists())
    {
     System.out.println("deletestart");
     Enumeration list = fdir.list();
     if (list.hasMoreElements()) {
      while (list.hasMoreElements()) {
       String str = (String) list.nextElement();
       System.out.println(footPath + name + "/"+str+" str:");
       fc = (FileConnection) Connector.open(footPath + name + "/"+str,
         Connector.READ_WRITE);
       fc.delete();
      }
     }
     fdir.delete();
     System.out.println("deleteend");
    }
    
   }

  } catch (IOException ex) {
   //ex.printStackTrace();
  }
  
 }
//重命名

fc.rename(String filename) //可以是文件,也可以是目录

/////////////////////////////

 Moto E2,E8上测试
 注意:moto手机对语句player.deallocate()不能释放player资源
  造成重复load声音文件时创造出了多个player,必须使用player.close()完全释放资源

if(player != null && player.getState() != Player.CLOSED)
   {  tmp=1;
    player.stop();
    player.deallocate();
    player.close();//必须存在此句话否则在多次player = Manager.createPlayer(FileURL);后出现多个player导致出现异常MediaException---->存在多个player,需要关闭其中的一些player
   } ------------------------------------------------------------------------------------------------------------------------

原创粉丝点击