Apache Ftp server integration with Android

落花浮王杯 提交于 2019-12-04 20:24:52

I've have had the same problem, so I've created my custom new users.properties file. Here it is the code:

    File files=new File(filepath + "/users.properties");  
    if (!files.exists()) {
          try {
              files.createNewFile();
          } catch (IOException e) {
             Log.e(TAG, "Errore nella creazione del file di log", e);
              e.printStackTrace();
          }
    }
    userManagerFactory.setFile(files);  
    userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
    UserManager um = userManagerFactory.createUserManager();
    BaseUser user = new BaseUser();
    user.setName("xxx");
    user.setPassword("yyy");
    user.setHomeDirectory("/mnt/sdcard");

    List<Authority> auths = new ArrayList<Authority>();
    Authority auth = new WritePermission();
    auths.add(auth);
    user.setAuthorities(auths);

    try {
        um.save(user);
    } catch (FtpException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!