androidstorageinternal

Android create folders in Internal Memory


Is there any way/ is it allowed to create folders in Internal Memory in Android. Example :

- data
-- com.test.app (application's main package)
---databases (database files)
---files (private files for application)
---shared_prefs (shared preferences)

---users (folder which I want to create)

Can I create users folder in Internal Memory for example?


Solution

  • I used this to create folder/file in internal memory :

    File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir;
    File fileWithinMyDir = new File(mydir, "myfile"); //Getting a file within the dir.
    FileOutputStream out = new FileOutputStream(fileWithinMyDir); //Use the stream as usual to write into the file.