Help coderanch get a
new server
by contributing to the fundraiser

Chris Trout

Greenhorn
+ Follow
since May 05, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Chris Trout

Thanks very much for your recommendations Monu.
I will try that the next time I have problems with "adb".

I'm also wondering if I have the most current versions of "adb" and the other tools.
Do you know how I can ensure that I do?

-Chris
14 years ago
I have been doing some research on this question and I'm wondering if any SQLite database used in an Android application needs to be created via the application code.
For example, if I create the database and load it ahead of time (which is typically what is done with a db used exclusively for look-up tasks) and place it in the "assets" folder of my Eclipse/Android project structure, do I need to open that file and read it byte-by-byte into a new (db) file I create.
From there I'm thinking I would use existing SQLite methods to open and access the db.

Any assistance on how to do this would be greatly appreciated.

Thanks
-Chris
14 years ago
I do not own an Android phone and am working exclusively in the Eclipse/emulator environment on my laptop.

When I type in the "adb shell" cmd from the tools directory I get very inconsistent results.
Sometimes it says "error: device not found".
Sometimes it says "error: device offline".
If I start a small application and continue to type in the "adb shell" command until the emulator starts I get the 2 errors I just mentioned in that order and then the "adb shell" command actually works and I can see the "#" prompt, and type in commands such as "ls -l" and see the results.
Then as I'm working in the shell it suddenly ends and I'm back at the Windows prompt.
I am running on Windows XP Pro Version 2002 Service Pack 3.

I would very much appreciate some help with this situation.

Thank You
-Chris
14 years ago
I have created and loaded a small database via the SQLite3 command line tool.
I am developing in Eclipse and using the emulator to test with.
I would like to know what the accepted practice is for where to put the database in my Eclipse Android project folder structure, and how to access it in my java code.
It would also be good to know how to test for the existence of the database file before trying to open it as I think the method will create it if it doesn't exist and I don't want that.

Thank You in advance to those wishing to reply.

-Chris
14 years ago
My apology for not attaching the code examples.
I'll blame that one on being new to the ranch...

I tried changing the version number of the db and that caused the tbl (not the db) to be dropped. That's good, so that problem is solved.

You mentioned that there are Android db code samples available.
I need to be able to state somewhere in the code where I want the db created initially. In my case I think it should be under that assets folder in the Eclipse Android project structure. Is that where db files should reside in the dev env? Or do people usually specify another folder under it called "databases"?

Finally, if you could point me to some relevant code example I would greatly appreciate it.

-Chris
14 years ago
Hi Tim,
Thanks very much for your reply.
As I was waiting for a reply I was thinking that I probably didn't do a very good job of explaining my problem, so I'm going to elaborate.

I am working exclusively in Eclipse currently as I don't have a phone.
I would like to use a SQLite look-up table in my app.
There is a database example in the Hello, Android book (starts on p. 170 as I recall).
It creates a sqlite db from within the app. That is interesting and I will use that technique in the future on some app I'm sure.
Although it doesn't seem to work exactly as advertised. It creates the db and tbl the first time thru but doesn't drop the tbl when it run it again. It just keeps adding
records to the table. Here is the relevant db code:

Here is the Constants interface -

package com.example.events;

import android.provider.BaseColumns;

public interface Constants extends BaseColumns{
public static final String TABLE_NAME = "events";

// define the Columns in the Events database
public static final String TIME = "time";
public static final String TITLE = "title";



}


Here is the class that extends SQLiteOpenHelper -

package com.example.events;

import static android.provider.BaseColumns._ID;
import static com.example.events.Constants.TABLE_NAME;
import static com.example.events.Constants.TIME;
import static com.example.events.Constants.TITLE;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class EventsData extends SQLiteOpenHelper {


private static final String DATABASE_NAME = "events.db";
private static final int DATABASE_VERSION = 1;

// create a helper object for the Events database
public EventsData(Context ctx) {
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + TIME
+ " INTEGER," + TITLE + " TEXT NOT NULL);");
}

@Override
public void onUpgrade(SQLiteDatabase db, int OldVersion,
int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);

}

}

* The tbl is never being dropped. I have set debuggable to try in my manifest file and set a breakpoint in this method to see if it is being invoked but it doesn't stop at that breakpoint or any other breakpoint I set in the app. I don't understand why?

I have looked all over for the events.db file but can't find it anywhere.
In actuality, I would like to have it be created under the "assets" folder in the Eclipse project structure for my Android project, but don't know how to tell to do that.
Would you be able to help me understand how to do that?
Once I understand that I can go onto my next little learning app where I put a look-up db into that same place and open it from there. Not exactly sure how to do an open on an existing db but will try and figure that out once this problem is solved.

Thanks again for your assistance as I am looking forward to hearing back from you.
-Chris
14 years ago
My apology in advance if I am posting this question in the wrong forum. I looked but did not find a better place.

My question is this - I am working thru the Hello, Android book examples and have successfully run and understand the Events database example on pages 170-180.
[ although I don't understand where the events.db file is being created.]
So, I decided to use the sqlite3 cmd line interface to create a different database, some tables, and write a small Android program to manipulate it.
I can invoke sqlite3 just fine from the cmd prompt, the db gets created and can create new tables, etc.
When I close sqlite3 I can see my new database.

What folder in my new Android program project should I copy my new datase to and how do I tell my code where to find it?

Thank you very much in advance to anyone who would like to offer some help.

-Chris
14 years ago
Hi Cameron,
I have been working thru the Head First Java book the past few weeks.
I'd like to start using your study guides but am not sure what to order.
I would very appreciate it if you would please provide links to the 2 books on both Amazon and B&N.

Thanks in advance.
-Chris
14 years ago
Hey cameron,
Thanks again for your reply.
When you say "have the objectives by your side", I'm assuming there will be a list in one of your 2 books?

Also, I think I'm going to go ahead and order your 2 books.
Can you please provide links to the 2 books I should order from either Amazon or B&N?

Thanks in advance
Chris
14 years ago
Thank you Monu and Ulf for your responses.
I am currently working thru the Head First Java book.
I think it will be a good re-learning resource.

I'm prob also going to pick up a copy of hte Thinking in Java book.

As far as phones go, cash is a little tight right now so I may hold off for a while and work with the emulator. But then again some of the new phones look really cool.

I did make contact with a couple of people who are interested in starting up an Android learning group here in Mpls.
I hope it happens as I'm pretty excited about the capabilities of Android and really want to learn how to use them effectively.

Have a nice weekend!

-Chris
14 years ago
Thank you everyone for your input.
I decided to go with Notepad++.
I'm really not challenging it much but it seems fine for what I need it for now.

I'm wondering if there is a way to tell it to compile a source file or many source files?

-Chris
14 years ago
Hello Everyone,
I am starting to work thru the Head First Java book and need a simple editor.
I do have Eclipse installed. I was using it to play with Android.
I installed Java version 1.6.0_18 SE on my computer so I could work thru the book.
Can I use Eclipse as my editor with this vesion of Java? Or should I download a simple Java editor?

Thank you in advance.
-Chris
14 years ago
Hi Cameron,
Thanks very much for your reply.
I have about a year's worth of Java programming experience, but that was approx. 10 years ago.
Based on what you said my understanding is that I should work thru the Head First Java book and then start to work thru your study guide; not the other way around.
Please confirm.

Also, I have read where some people are having trouble getting your 2 books in a timely manner.
Can you please recommend a source where I can get them from quickly.

-Chris
14 years ago
Hello Everyone,
I am a new member to the Java Ranch and am really enjoying perusing some of the forums.
I am returned to programming after a long absence. I have approx. 1 year of Java programming experience, but that was approx. 10 years ago.
I've come to the conclusion that a good place to start would be to build my knowledge of the language by getting a SCJA and then go on from there.

I see that there are a number of books out there people have recommended to start with as well as study guides.
Cameron's study guide and questions seem to be highly and often recommended. Please do recommend others if you feel they may work better.

What I need is some direction. What path should I take?
Should I get a book like Just Java 2 or Head First Java (definitely open to other book suggestions), work thru it and then start going thru the study guides and questions?
Also, I've read that an additional UML resource would be a good idea.

Thank you in advance for your advice.
-Chris
14 years ago
Monu, Thanks very much for your reply.

I have a couple more questions.

1.
You mentioned -

"However, note that the version of Java compiler used in Android is 1.5 and later so it would be better you also read up upon concepts that were introduced with these versions(annotations, generics to name a few). "

I'm unclear what version of the Java compiler is covered in the Just Java 2 book. Can you recommend a source for me to read up on the concepts you think are not covered in the book (annotations, generics, etc.)?

2.
I would like to improve my ability to think in OO concepts. I have had a course in that topic some time ago. I came across a book called thinking In Java. Would that be a good book to improve my skills in that area or can you recommend a better one?

3.
Regarding a first smartphone to start developing on, are there companies that cater to developers? What I mean by that is, is there a plan (and phone) that I could get that is not very expensive?

4.
Finally, how can I found out if there is an Android User Group in Minneapolis/Minnesota? I would really like to meet others who are starting to develop on this platform and share ideas/questions.

Thank you very much for your time. As you can see I am in a transition state with my career right now and do appreciate all of the support this site can provide.

-Chris

14 years ago