0

I want to assignt my CSVreader from the openCSV api to a CSV file, but it can't find it, as I get an "cannot resolve symbol" error.

code:

 CSVReader csvReader = new CSVReader(getAssets().open(testCSV.csv));

I'm using Android Studio, and the file is located under src/main/assets/

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chimpanse
  • 250
  • 1
  • 5
  • 17

2 Answers2

0

You have to call getAssets().open("myFile") on your current context. so give your context to the function, like this:

public void openFile(Context context){
    CSVReader csvReader = new CSVReader(context.getAssets().open("testCSV.csv"));
}
PKlumpp
  • 4,913
  • 8
  • 36
  • 64
  • should i then be calling openFile(); in onCreate, becuase when i do that i get an error – Chimpanse Jun 17 '14 at 21:40
  • See here http://stackoverflow.com/questions/4410328/how-to-obtain-assetmanager-without-reference-to-context and also have a read here http://developer.android.com/reference/android/content/Context.html – andyw_ Jun 17 '14 at 21:44
  • in my Andoid manifest it says android:name cannot be assigned to app. – Chimpanse Jun 17 '14 at 22:09
0

This probably means testCSV.csv needs to be a string so "testCSV.csv" with the quotes

andyw_
  • 490
  • 5
  • 15