Android :: How To Use Other External Cursor / Prepare By SQL Database?

Sep 21, 2009

In the API Demo, there is example on using Simple Cursor Adapter. However, it is using the MediaS tore cursor. Is there any method so that I can use other external cursor prepare by SQL database. I don't know what should I input to the from String.

Android :: How to use other external cursor / prepare by SQL database?


Android :: Join ContentResolver Cursor With A Database Cursor

Mar 21, 2010

I get records from the system by quering a ContentResolver. I maintain the order of the items in the database. So I want to display the items in the order taken from my database.

How do I merge these two informations?

I am looking after an alternative way now. As what I ideally want is:

Get order of contacts by a custom order held in my database (this involves joining CR with my DB cursor, and doing an order by, later seams it's not possible with CursorJoiner) but there is more, if the join is not unique I want to sort by contact's name as last measure

Which is impossible using Cursor and Joiners, because of the missing feature of order bys, also I need to return a Cursor, as I will be using the in an ExpandableList

Also this translated to TSQL it would look like

select * from contactsdata
left join category on contactsdata.catid=category.id
order by category.pos asc, contact.display_name asc

So I am looking now after an alternative. I have in mind to load in a temporary DB table all data from CR, then do the query on the temporary table where I can join tables and do order bys? How does this sound to you?

View 1 Replies View Related

Android :: How To Import Cursor From Database Class Into Current One?

Jul 1, 2010

Here is my code for my db class:
package one.two;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import java.util.ArrayList;
public class DBAdapter extends ListActivity
{public String status = "status";
public String id = "id";
public String arrival = "arrival";
public String destination = "destination";
public String ferry = "ferry";
private static String DB_PATH = "/data/data/one.two/databases/";
private static final String DATABASE_NAME = "ferry.db";
private static final String DATABASE_TABLE = "port";
public static Context context;
public Cursor c;
public static SQLiteDatabase DbLib;
//overloaded non-null constructor
public DBAdapter(Context context) {
DbLib = context.openOrCreateDatabase(DATABASE_NAME,
SQLiteDatabase.CREATE_IF_NECESSARY,null);
System.out.println("OpenOrCreateDB Done");
} public class DatabaseHelper extends SQLiteOpenHelper {
Context context;
DatabaseHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
}//end constructor DatabaseHelper
// ---closes the database---
public void close() {
DBHelper.close();
}//end close()
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion){
}//end onUpgrade()
@Override
public void onCreate(SQLiteDatabase db){
}//end onCreate()
}// end class DatabaseHelper
private static DatabaseHelper DBHelper;
private static final int DATABASE_VERSION = 1;
public static ArrayList<String> getAllTitles(){
ArrayList<String> port = new ArrayList<String>();
Cursor c=null;
c = DbLib.query("port"
new String[] { "status", "id", "arrival",
"destination", "ferry" }, null, null,
null, null, null);
try {
if (c!=null) { // start - when there is at least 1 record
System.out.println("Cursor is NOT NULL");
int i =0;
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
{// Debug Stm
System.out.println("Record No. "+i);
System.out.println(c.getString(0));
System.out.println(c.getString(1));
System.out.println(c.getString(2));
System.out.println(c.getString(3));
System.out.println(c.getString(4));
// Assign database cursor.records to arraylist
port.add(i,c.getString(0));
port.add(i,c.getString(1));
port.add(i,c.getString(2));
port.add(i,c.getString(3));
port.add(i,c.getString(4));
i = i + 1;
} } // end - where there is at least 1 record
} finally {
if (c!=null) {
c.close();
} } return port;
}//end getAllTitles()
public void open() {
//Open the database
String myPath = DB_PATH + DATABASE_NAME;
DbLib = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
} }//end class DBAdapter
My Arrival class
package one.two;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
public class Arrival extends ListActivity
{ private ListView listView;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{ ArrayList<String> retList = new ArrayList<String>();
System.out.println("Start onCreate Function");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println("In onCreate Function");
System.out.println("In of GetData");
DBAdapter db = new DBAdapter(this);
System.out.println("DB Open");
db.open();
System.out.println("DB Opened");
retList = getData();
System.out.println("Out of GetData");
// force count no. of records in table
// dump to check index
int cnt = 2;
int i=0;
for (i = 0; i<cnt; i++)
System.out.println(retList.toString());
listView = (ListView) findViewById(android.R.id.list);
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.id.list, null, null, null);
this.setListAdapter(mAdapter);
// db.close();
} @SuppressWarnings("static-access")
public static ArrayList<String> getData()
{ ArrayList<String> items = DBAdapter.getAllTitles();
// titles ???? redundant
//ArrayList<String> titles = new ArrayList<String>(items);
System.out.println("Return a LIST titles");
return items;
} }

View 1 Replies View Related

Android :: Trying To Write Custom Adapter For Database Cursor

Jun 29, 2009

I been using custom adapters based on the BaseAdapter and I usually populate my data at the getView() funtion.

Now I'm trying to write my custom adapter for my database cursor which now will be based on a CursorAdapter.

I'm getting confused where I should do the populating work? Along with how do I implement my inflating and populating "smart/efficient code based on RomainGuy presentation."

View 8 Replies View Related

Android :: Finalizing Cursor Android.database.sqlite.SQLite­Cursor

May 6, 2009

I am seeing the exception in 'adb logcat'.But I don't know if it is caused by my application or android platform.Can you please give me any idea how to troubleshoot this exception?

View 3 Replies View Related

Android :: Populate A Spinner From Cursor Accessing An SQLite Database?

Aug 25, 2009

How do you populate a spinner from a cursor accessing an SQLite database?

View 2 Replies View Related

Android : Working With SQLite Database / Getting Cursor Out Of Bounds Exception

Jun 30, 2009

I am having some trouble working with the SQLite database. I am able to create the database, add to it, and delete from it with no problem by following the Notepad examples, but I am trying to avoid duplicates and therefore want to check to see if an entry exists already.

Below is the code I have for testing to see if a game exists. I get the correct Log message of "No Games" when there are no games, as well as the correct value for column from getColumnIndex which is proven to me by the log printout telling me that column = 1.

The error message that I receive if I don't catch the exception says "Caused by android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1

Where is Index -1 being requested if my call to getColumnIndex is returning 1? Code...

View 3 Replies View Related

Android :: App To Connect To An External Database And Pull Certain Columns?

Oct 2, 2009

I am working on an app that will need to connect to an external database and pull certain columns. I am looking for some help in opening a connection to the database. In another words, something like ODBC or JDBC in web development.

View 4 Replies View Related

Android :: Access External Database From Droid Application?

Mar 17, 2010

I'm new bie to android.. i want to access external database from my android application.. I've searched so much time in the Internet but could not get exact idea how to implement?

Please help me If any one is having idea on that and post if u have any code related to it.

View 24 Replies View Related

Android :: Move Cursor In On-screen Keyboard With External Keyboard

Nov 1, 2010

I am new in Android and i am working to make an on-screen keyboard which can be visitable via arrow(direction) keys of my external keyboard. I mean i wanna move left, right, up and down in the on-screen keyboard's UI (keys) with pressing arrow keys from my external(hardware) keyboard. The key that cursor is on should be focused, when i press an arrow key from my external keyboard the focused key should change and when i press "enter" from my external keyboard it should be operated.(written to the screen etc.) How can i make this? Is there any idea? How can i make virtual keyboard's keys visitable? It doesn't look like moving around a matrix of buttons.

View 2 Replies View Related

Android :: Android.database.StaleDataExce­ption Access Closed Cursor

May 18, 2010

I have activity A and I used managedQuery in Activity A. I have an adpater which extends from BaseAdapter. In GetView I access the mcursor to get fields.If I click a button on Activity A it goes to B, A---> B.The problem arises when I am in activity B *and it's visible(B), the error is thrown from Acitivity A.I dont understand why I get the error from Activity A. Activity B is visible now and A is in background.There was a post already on this group with similar error but there was no response.I was hoping if someone encountered this and found a solution.

View 2 Replies View Related

Android :: Open Helper To Open Database And Get A Cursor To Pass To CursorAdapter

Jul 1, 2010

I have a ListActivity that uses a CursorAdapter to fill the rows in the view. I wrote a database helper class that gives me back results for common queries I make for my app, and it uses an SQLiteOpenHelper implementation I wrote to open the database. I use the open helper to open the database and get a cursor to pass to my CursorAdapter.

Here's a code snippet:

CODE:...................

The problem I'm having, that I didn't have before I implemented the open helper (before I just opened the database directly without a helper), is when I click on an item, which takes me to another activity, and then go back to this activity. When it initializes everything is fine, and my list is populated fine, but when I go back from the activity that follows, the list is empty and in the LogCat I see "Invalid statement in fillWindow()".

It appears from a few post I've seen that the reason is, when I requery the cursor, the database is closed. But I'm not closing it! I'm scratching my head on this one.

View 2 Replies View Related

Android : Adding A "column" - Data To A Database Cursor

Jan 10, 2010

Maybe I'm going about this the wrong way, but if so, please correct me. Here is the situation: I have a query which returns URI strings for ringtones stored in a database.

I am trying to add a "column" to this cursor with the ringer "Title" (since this can change outside my program). I can successfully user RingtoneManager to get the title, but I cannot figure out how to add this "column" to the cursor data for later use. Here is what I have so far: Code...

View 2 Replies View Related

Android :: Moving Cursor Adapter Cursor Creation To Background Thread

Mar 29, 2010

The structure of some of my activities is a simple ListView with a custom CursorAdapter. The cursor is created in onCreate() on the activity from a SQLite database. The problem is that querying the SQLite database can be quite slow at times with lots of data (and let's assume I've already optimized the sql query as much as possible). Because it occurs in onCreate() on the UI thread, I get ugly black screens when opening the activity, which sometimes turn into ANRs, on a slow phone like the G1. I want to load the cursor in a background and show "Loading.." on screen while doing so. I saw AsyncQueryHandler used extensively in the framework, but this seems a solution geared more towards Content Providers and not application-local SQLite databases. I then thought of trying to load the cursor in a background thread, but realize that this might be problematic, as the CursorAdapter should be instantiated in onCreate() and should take a cursor as a parameter. The latest thought I had was to instantiate an empty MatrixCursor in onCreate() and pass that to the cursor adapter, while kicking off a thread/TimerTask to query the database. Then, on database cursor load, call cursorAdapter.change Cursor to the properly filled cursor. This doesn't seem very elegant and seems quite wasteful, however.

View 10 Replies View Related

Android :: Looper - Prepare

Sep 27, 2010

I'm trying to initialize OpenFeint in my game like this:

CODE:...........

Result: 1. OpenFeint initialization sometimes take so song(network actions?). It blocks the main thread. 2. My application remains in onCreate() for too long. 3. My Dev Phone One display ANR(application not responding) dialog prompting me to choose between 'Force Close' and 'Wait' 4. Soon after that, OpenFeint has done its things and my game shows up behind the dialog. 5. Now pressing 'Wait' will dismiss the ANR dialog and I can continue my game properly.

But obviously we don't want ANR dialog. So now I put it in a Thread like this:

CODE:...............

---------------------------------------------------------------------------­-- Result: Problem solved. Everything seems to run fine now.

I put Looper.prepare() there because my game will crash if I don't. The log message told me to put it there. I put Looper.loop(); there because OpenFeint will not initialize at all if I don't. I've read the doc about Looper but honestly I don't understand what the doc says.

Question 1. The doc also tell me this: ------------------------------------------------- public static final void loop ()

Since: API Level 1 Run the message queue in this thread. Be sure to call quit() to end the loop. -------------------------------------------------- Can anyone explain when & where should I call quit()?

Question 2 What will happen if I don't call Looper.quit()?

Question 3 Let me ask this straight. Am I taking the correct approach? Is there some kind of loop running alongside my game all the time if I do this?

View 5 Replies View Related

Android :: Prepare The UI From The Webservice

Aug 30, 2010

Playing around with the UI and SQLLite for a while and it looks pretty good to me . We have a requirement that for the App that all the questions would be coming from the server through REST / Web service which would be displayed on the App..

say for e.g if there are 4 questions
1) Enter your Name -- Text Box
2) Did you sleep well last night -- YES / NO
3) How many hours did you sleep - Text Box
4) How did you hear about us -- Drop down

So the requirement is that the Questions would be displayed on the App after doing a SYNC with the server during the SYNC with the server the Questions would be downloaded from the SERVER through REST / Web service..if the phone is not connected then pull the questions from the Database...

These questions are simple questions and they change quite often and we have a similar app which is there for iphone which does this ....

View 1 Replies View Related

Android :: Camera Prepare Fails

Sep 10, 2009

I'm trying to build a simple video recorder for an Android device and I've had limited success and mixed results. It worked once, but now, without changing anything, I'm getting a "Camera is not available" error followed by "prepare failed -2147483648" error.

View 1 Replies View Related

Android :: Prepare Failed In MediaRecorder / Way To Fix

Jul 3, 2009

I am trying to develop an application with Android 1.5(cupcake_r1) for a week but always get an error reported in prepare of MediaRecorder. Can anybody help me to figure out the problem I got in the code below:

PS. In order to figure out the problem, I suppressed the audio recording, and the SDcard is installed in the phone.code...

View 3 Replies View Related

Android :: Api I Can Use To Prepare VCard In Droid?

May 18, 2010

I am preparing a contacts application and would like to support the VCard export. Can anyone tell me if there is any API I can use to create a VCard.

View 4 Replies View Related

Android :: Media Recorder Prepare Causes Segfault

Mar 28, 2010

I have a situation where my MediaRecorder instance causes a segfault. I'm working with a HTC Hero, Android 1.5+APIs. In the log i see (after the segfault announcement) a register dump and then a numbered list #00 libmedia_jni.so to #18 linker, then a stack trace. My Eclipse won't let me copy the log buffer, but I've done three screen captures that sum it up. If you have time to examine, send me a direct e-mail.<pre><code> if (mRecorder == null) mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);// mRecorder.setVideoSize(640, 480); // mRecorder.setVideoFrameRate(20); mRecorder.setPreviewDisplay(surfaceHolder.getSurface()); mRecorder.prepare();mRecorder.start(); </code></pre> I've tried other variants, including H263 and 3gp. What else can I do to debug this? Everythin g seems fine up to prepare(). I tried adding the onErrorListener, but it seems to interfere with the MediaPlayer's onErrorListener. I'm using a 4-second beep-count to prepare for auto triggering of the camera, and when I enable the error handler for the MR everything in my handler state machines goes awry.

View 4 Replies View Related

Motorola Droid :: How To Prepare For Android Update 2.2 (Froyo)?

May 22, 2010

Since no one knows when the update is going to come to the Droid. Could be tomorrow or in three months. Its all up in the air. It could happen anytime. Anyways, What do you need to do?

Have a battery near full all the time?
Backup your Aps?
Backup contacts?

Since I am assuming you can get the update without warning, I just wanted to know what steps to take, so I can have no problems with an OTA update.

View 11 Replies View Related

Android :: Need To Prepare KML File For Droid Emulator Control

Jan 21, 2010

I am trying to test my application with location information.
You know the Emulator Control has an ability to load from KML file. (Eclipse -> DDMS -> Emulator Control -> Location Controls -> KML -> Load KML...)
I've prepared KML file using Google earth application with its "Add path". Then saved it by .kml extension and load it on the Eclipse. Eclipse didn't load this KML file.

How to prepare KML file for Android Emulator Control?

View 1 Replies View Related

Android :: MediaPlayer.setDataSource - Fd - Cause IOException: Prepare Failed - Status - 0x1

Aug 6, 2009

What is the preferred way of reusing a MediaPlayer when using resources? My try looks a bit ... too complicated... so maybe I should be happy to see that it didn't work. (I run the Android 1.5 SDK and emulator.)

According to this thread my problem may be a permission problem. http://groups.google.se/group/android-developers/browse_thread/thread...

I get the same error. But in my case it only occurs when I use FileDescriptor!?! The use case differs however, because I use a resource stored in the bundle. I have s0.mp3 safely stored in the project /res/raw and it successfully plays when I use SoundPool or MediaPlayer.create. And the log print tells me I referenced the correct file and stay safely in my package.

I'm sure my way of getting the fd out from a package resource is the problem, I didn't find any other way... But why didn't setDataSource throw the exception instead of a printout? And why on earth is the same resource happily played one way but not the other? Seems like a design flaw rather than a security raise. Should I look in the MediaPlayer.create code to see how they get around the problem or can you help me understand how it works?

This is a test code snippet: (from onCreate of a simple Activity)

CODE:...........

And the error:

CODE;..............

View 2 Replies View Related

Android :: MediaRecorder Error: Java.io.IOException: Prepare Failed

Sep 8, 2009

I am trying to write a sample program to record the video (say camcorder application). When i run my program using the emulator (I have android-sdk- windows-1.5_r3) I see java.io.IOException: prepare failed. error in logcat output.

Further I can see that I have came across this error when i call MediaRecorder.prepare() from CamcorderActivity.surfaceCreated() But I am surprised to see that activity got launched and I am seeing the camera preview! Again the preview is seen only in half of the screen! Its weird!!!

Further when i do recorder.start() to record the video I get java.lang.IllegalStateException. Yes this is obvious since the prepare () has failed. But the question is why prepare() has failed ?

Here is my code ... package com.example;

CODE:................

View 2 Replies View Related

Android :: Can't Create Handler Inside Thread That Has Not Called Looper.prepare

Oct 6, 2010

What does the following exception mean? And how can I fix it?
This is the code:Toast toast = Toast.makeText(mContext, 'Somthing', Toast.LENGTH_SHORT);
This is the exception:
D/VVM ( 684): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
D/VVM ( 684): at android.os.Handler.(Handler.java:121)
D/VVM ( 684): at android.widget.Toast.(Toast.java:68)
D/VVM ( 684): at android.widget.Toast.makeText(Toast.java:231)

View 1 Replies View Related

HTC Aria :: AT&T / ROM To Prepare For OTA Firmware Updates

Sep 16, 2010

Looker, lookie, new Aria ROM to allow OTA firmware updates, plus two other bug fixes. I think they are gearing up for Android 2.2, HTC Mobile Phone Support - HTC Aria? (AT&T) - Downloads

View 1 Replies View Related

HTC Incredible :: Prepare Sd Card And Phone Keeps Shutting Off

May 8, 2010

i have no idea why it is turning off i got the phone yesterday. would it be because it is trying to prepare my sd card?it started when i put the card in.

View 4 Replies View Related

Samsung Vibrant :: Want To Prepare Phone To Be Returned To Tmobile / Fix It?

Sep 21, 2010

I've been having an issue with my headphone jack and finally called into Tmobile tech support.
They are going to be sending a replacement phone, so I would like some help on how I can get my current phone ready to be sent back to them.

Currently it is rooted stock 2.1 and has ryanza lag fix applied.
Most of my files are on the SD.

I know I need to unroot, how would I proceed to do that and would unrooting get rid of the lag fix?

View 16 Replies View Related

Android :: Android - Can't Handler Inside Thread Not Called Looper Prepare

Sep 30, 2010

I am getting reports of 'Can't create handler inside thread that has not called Looper.prepare()' once I added ScoreNinja to my Android app, and released it to the market. It seems that it isn't happening all the time as the ScoreNinja highscore has lots of entries from users. I have looked on the web for help but there are no clear directions on what to do. I have used the ScoreNinja code exactly as shown on the scoreninja website. BTW If anyone is having problems with ScoreNinja only displaying one score, check to see if the launchmode is not set to 'singleinstance' in your manifest. This fixed it for me!

View 6 Replies View Related

Android :: Connect To Remote Database Online Database

Nov 8, 2010

ive been looking for a week now i need some help connecting to a remote database...i want my app to get data out of the database and update the database.ive tried this http://www.helloandroid.com/tutorials/connecting-mysql-database but i dont understand it.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved