Android 1.6 SDK - Internal File Path Issue
I am trying to read a csv file from assets/file.csv, but the log keeps spitting out that it doesn't exist. Is my path correct for internal file storage? This is the class file:
package com.xxx.view;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.开发者_运维问答io.IOException;
import java.util.StringTokenizer;
public class ReadList {
    public String[][] mainMenuList() throws IOException {
        String [][] arrayList = new String [24][24];
        File file = new File("/data/data/com.xxx.view/file.csv");
        BufferedReader bufRdr  = new BufferedReader(new FileReader(file));
        String line = null;
        int row = 0;
        int col = 0;
        while((line = bufRdr.readLine()) != null && row < 24) { 
            StringTokenizer st = new StringTokenizer(line,",");
            while (st.hasMoreTokens()) {
                arrayList[row][col] = st.nextToken();
                col++;
            }
            col = 0;
            row++;
        }
        return arrayList;
    }
}
Android doesn't let you access files on the phone's storage that way.  You can only access files on the SD card via a traditional java File interface.  Check out the AssetManager docs for more information.  Also, check out this SO post for a similar example.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论