I wrote a sketch that opens and reads a .db file of about 200,000 stars. In Processing 3 on desktop it reads the db file, uses a specific query to get about 6000 stars that are displayed as texture.point(X,Y). I took that code and stuck it in an android studio project and uploaded it to android. The processing code works except when I run debug the app, the debug window shows the following error:
W/System.err: java.sql.SQLException: opening db: ‘/hygdata.db’: open failed: EROFS (Read-only file system)
I moved the db file into the same directory as the mainactivity and the class file with the processing code. This only changed the error from access denied to EROFS, but nothing I’ve tried will let SQLite open and read the db file. I even tried lowering the target api to 17.
How do I get it to load and open? I don’t have an SD card and just using the internal storage.
Here’s a shot of what it looks like on the desktop. The texture image used is of all the constellations. My database query gets the right ascension and declination for stars in Gemini, Ursa Major, and Ceph. The code I’m posting is of the function that reads the database and makes texture.points of the stars in the search.
public void addDiagonalLine2(){
texture.beginDraw();
if ( db.connect() )
{
String[] tableNames = db.getTableNames();
db.query( "SELECT ra,dec,proper,con FROM %s WHERE proper > ' '", tableNames[0] ); // AND dist <= '30.65' OR proper > ' ', tableNames[0] ); // AND mag >= '5.0' AND mag <= '5.05'", tableNames[0] );
db.query( "SELECT con,ra,dec,proper FROM %s WHERE proper = 'Arcturus' OR proper = 'Vega' OR proper = 'Dubhe' OR con = 'Lyr' OR con = 'Cep' OR con = 'UMa'", tableNames[0] );
int i = 1;
while (db.next())
{
TableOne t = new TableOne();
db.setFromRow( t );
float ra = (float)(t.ra);
float dec = (float)(t.dec);
String starName = t.proper;
float RA = 1.0 * ra; // (DeciGAST * ra);
println(i,t.con,t.proper, t.ra, t.dec);
RA = 1.0 * ra; // (DeciGAST * ra);
RA = (24 - (float)GAST) + ra;
if (RA < 0 ){
RA = 24 - RA;
}
if (RA > 24) {
RA = RA - 24;
}
i++;
RA = map(RA,0.0f, 24.0f,0,TWO_PI);
float X = map((RA),0,TWO_PI,texture.width -texture.width,texture.width);
float Y = map(radians(dec),radians(0),radians(90),texture.height/2,texture.height - texture.height);
texture.stroke(0,255,0);
texture.strokeWeight(6);
if (X > texture.width/2){
texture.point(texture.width/2+(texture.width-X),Y);
}
if ( X < texture.width/2) {
texture.point((texture.width/2-X),Y);
}
texture.point(-X,Y);
}
}
.
And here’s a shot of how when I mouse press the upper left of the screen, the position of the X,Y points changes according to Greenwich apparent sidereal time. It’s rotating counter clockwise. I’d like to be able to press the clock button and have it all rotate together. That wouldn’t need a mouse press to update the X,Y.
And I solved it, maybe, by using the Ketai SQLite. I say maybe because it now can open and read the db file. I changed the extension from .db to .sqlite like the example and when I run debug the app, it shows that the file was found, opened. I have no idea what Ketai does to make that happen, but I will see if I can adapt my query.
Edit #2: I read the reference for Ketai’s SQLite and I have no idea how to use it. It completely redefines SQLite. I just want to do a query and return some data. Their example only opens a file and then tells you how many entries are in a table. That’s frustrating junk.
Edit #3: I read the source code for KetaiSQLite.java and tried a few things that led me to the answer that actually worked. I tried a few of the functions and got the name of the table in my database file. I used that table name in my query and it worked on Android. The screenshots from the desktop are exactly as it appears in Android now. No more frustration with Ketai, I can focus on improvements now.
1 Like