2016年12月25日日曜日

Android 外部存储

Android 外部存储

https://developer.android.com/guide/topics/data/data-storage.html



    protected void saveto() {
//        I/System.out: this.getDatabasePath("test")
//        I/System.out: /data/user/0/com.example.e560.m1224a/databases/test
//        I/System.out: /data/user/0/com.example.e560.m1224a/databases/test
//        I/System.out: /data/user/0/com.example.e560.m1224a/databases/test
        File f1 = this.getDatabasePath("test");
        System.out.println("this.getDatabasePath(\"test\")");
        System.out.println(f1.getAbsolutePath());
        System.out.println(f1.getPath());
        System.out.println(f1.toString());

//        I/System.out: /storage/emulated/0/Android/data/com.example.e560.m1224a/files
//        I/System.out: /storage/emulated/0/Android/data/com.example.e560.m1224a/files
//        I/System.out: /storage/emulated/0/Android/data/com.example.e560.m1224a/files
        File f2 = this.getExternalFilesDir(null);
        System.out.println("this.getExternalFilesDir(null)");
        System.out.println(f2.getAbsolutePath());
        System.out.println(f2.getPath());
        System.out.println(f2.toString());

//        I/System.out: /data
//        I/System.out: /data
//        I/System.out: /data
        File f3 = Environment.getDataDirectory();
        System.out.println("Environment.getDataDirectory()");
        System.out.println(f3.getAbsolutePath());
        System.out.println(f3.getPath());
        System.out.println(f3.toString());

//        I/System.out: /storage/emulated/0
//        I/System.out: /storage/emulated/0
//        I/System.out: /storage/emulated/0
        File f4 = Environment.getExternalStorageDirectory();
        System.out.println("Environment.getExternalStorageDirectory()");
        System.out.println(f4.getAbsolutePath());
        System.out.println(f4.getPath());
        System.out.println(f4.toString());
    }

0 件のコメント: