4

We have a USB port in our android tablet(version 4.0.3).

Pendrive File Systems Format are

  1. NTFS
  2. FAT32

When Pendrive File Systems Format are FAT32 File has been created Successfully. But When File Systems Format are NTFS, I got the Error Message as open failed: EACCESS (Permission denied).

I Need to create a New File from in the USB Pendrive. I have tried my sample code is

Button createFile = (Button) findViewById(R.id.createFile);
createFile.setOnClickListener(new OnClickListener() 
{
    public void onClick(View v) 
    {
        try 
        {
            File root = new File("/mnt/usbhost1");
            Runtime.getRuntime().exec("chmod 777 " + root.getAbsolutePath());
            File myFile = new File(root,"createNew.txt");
            myFile.createNewFile();
            Toast.makeText(getBaseContext(), "Done Creating File", Toast.LENGTH_SHORT).show();
        } 
        catch (Exception e) 
        {
            Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }
});

Here /usbhost1 is a Android tablet USB Path. Where I am mistaken. How to create a New File from in the NTFS File Systems Format.

Thanks in advance.

Regards
Bala

Bala
  • 445
  • 5
  • 11
  • 26
  • the linux kernel in android supports fat 32 not ntfs you will have to use 3rd party progs to handle that – Athul Harikumar Aug 28 '12 at 08:07
  • @droidhot How to use 3rd party(specified which application) programs to my application. How to create a New File(NTFS) using my application. – Bala Aug 28 '12 at 08:20
  • refer this its not simple it will be a good start up i ll inform you if i find something usefull http://forum.xda-developers.com/showthread.php?t=1724078 – Athul Harikumar Aug 28 '12 at 08:50
  • Please tell me about... Thanks... – Bala Oct 06 '12 at 01:12

1 Answers1

2

What you need is a way to enable support for NTFS in the kernel on your device. This could be achieved dynamically by building the ntfs-driver as loadable module (.ko file). This would need to be done for the specific version of the kernel that is running on your device.

Next you need a way to automatically load the module each time the systems restarts. this is also "do-able" in Android. You might want to try this app which does precisely that. i.e. load one or more kernel module(s) located anywhere on the Android device.

After this whenever one inserts a external-device(usb-drive) that has ntfs partitions, the kernel will be able to properly recognise and mount it. Hence apps can then access it at its proper location like "/mnt/usbhost1" etc.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130