PowenKo, Android Tutorial 065-4, File, get Cache Dir, File Dir


package com.powenko.Tutorial_File_Temp_Cache_folder;

import java.io.File;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

public class Tutorial_File_Temp_Cache_folderActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TextView  textView1 =(TextView) findViewById(R.id.textView1);
        Context context = getApplicationContext();
        File	t_file1=context.getCacheDir();
        String t_path=t_file1.getPath();

        String t_path2=context.getFilesDir().getPath();

        textView1.setText("CacheDir:"+t_path+"\n FileDir:"+t_path2);

    }
}

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


Leave a Reply