Quantcast
Viewing latest article 9
Browse Latest Browse All 941

CSV file not found in android but no problem in processing 3

I started with a demo that uses a menu that allows to choose which sketch to run on android. I modified it to add my sketch to the menu. I took my sketch that works standalone on android and added it to the demo. My sketch reads a csv file and uses the data as input. Heres the link to the processing android demo: https://github.com/omerjerk/ProcessingAndroidDemo

When I add my sketch and the csv file to a /data directory, it crashes and I get a blue processing error message that says make sure the file URL is accessible or readable. The Java error is Nullpointerexception trying to determine the length of a null array. I tried putting the csv file in different project directories but it doesn't matter. I'm using Android studio if it matters.

Heres my code that I put in draw():

    String[] starLines = loadStrings("stardata.csv");
    println("Loaded " + starLines.length + " stars:");

    Lat = (float)Latitude_1 + (float)Lat_minutes/60 + (float)Lat_seconds/3600;  //Estimated Latitude
    Lon = (float)Longitude_1 - (float)Lon_minutes/60 - (float)Lon_seconds/3600; //Estimated Longitude

   if (Longitude_1 > 0) {
   Lon = (float)Longitude_1 + (float)Lon_minutes/60 + (float)Lon_seconds/3600; //East of Greenwich
   }

    for ( i = 0 ; i < starLines.length; i++) {

        String[] stars = splitTokens(starLines[i], ", ");
        String proper = (stars[0]);
        String con = (stars[1]);
        double dec = PApplet.parseFloat(stars[2]);
        double ra = PApplet.parseFloat(stars[3]);
        double pmra = PApplet.parseFloat(stars[4]);
        double pmdec = PApplet.parseFloat(stars[5]);
        double rv = PApplet.parseFloat(stars[6]);

        ra = ra * 15;

        Star1 = Name1.getCaptionLabel().getText();
        if (Star1 == "Procyon") {
            z = 47;

....

Any ideas where stardata.csv should go in the project, so it is "accessible" ?


Viewing latest article 9
Browse Latest Browse All 941