Search code examples
androidandroid-sdcard

Use phone internal memory Android


I want to read a file from the phone internal memory.I have two memory in my device that is sdcard0 and sdcard1.sdcard1 is phone internal memory.So my file is in the phone internal memory . It's path is /storage/sdcard1/Android/New_Data.xml.So is this right way to access or not Please suggest me what i have do for this

Code

File file=new File("/storage/sdcard1/Android/New_Data.xml");
        if (file.exists()) {

        }else{

        }

This is working fine but i want to know is this a right way or not


Solution

  • See this might help you '

    Read from here LINK TO UNDERSTAND

    String FILENAME = "hello_file";
    String string = "hello world!";
    
    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
    fos.write(string.getBytes());
    
    fos.close();