A Little Help Needed with a SQLite database to get a Ringtone Set

This is a discussion on A Little Help Needed with a SQLite database to get a Ringtone Set within the Android App Developers forums, part of the Droid Apps category; Basically what I want to be able to do is set a Default Ringtone from this particular activity. The idea of my APK I am ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: A Little Help Needed with a SQLite database to get a Ringtone Set

  1. Junior Droid
    r2sjoblom's Avatar
    Member #
    173795
    Join Date
    Feb 2011
    Posts
    10
    Phone
    droid x
    #1

    A Little Help Needed with a SQLite database to get a Ringtone Set

    Basically what I want to be able to do is set a Default Ringtone from this particular activity. The idea of my APK I am doing is a simple random ringtone sleector for the user. They will put a check mark next to the ringtones they want, which will populate a SQLite database then (this is my issue) randomly select a ringtone from the list in the SQL database. This is all fairly simple but I am just stuck on this next (last) part. Below is the code. I am trying two different ways to get it to work with different uri's, that is why I have two at the bottom. The Log.i's show the proper information. The proper database count, selecting a random number from the "_id" column, and finially selecting the actual uri from the "title" column. The problem is that the RingtoneManager.setActualDefaultRingtoneUri() is not working. I have used this method numberous times before but this is just a nightmare. Any help would be great. Thanks in advanced.
    Code:
    privatevoid setDefaultRingtone() {// TODO Auto-generated method stub
    //use the cursor from the sql database and set the default ringtone
    Random newrandom =
    new Random();dbCursor = mydata.getAllTitles();int Cursorcount = dbCursor.getCount();if (dbCursor != null) {int index = newrandom.nextInt(Cursorcount);dbCursor.moveToPosition(index);}int position2 = dbCursor.getPosition();long l2 = dbCursor.getLong(dbCursor.getColumnIndexOrThrow("_id"));String str = dbCursor.getString(dbCursor.getColumnIndexOrThrow("title"));Uri localUri2 = ContentUris.withAppendedId(MediaStore.Audio.Media.getContentUriForPath(str), l2);//Uri localUri = mRingtoneManager2.getRingtoneUri(dbCursor.getPosition());
    Uri localUri = Uri.parse(
    dbCursor.getString(dbCursor.getColumnIndexOrThrow("title")));Log.i("Ringtones", "music DB count: " + Cursorcount);Log.i("Ringtones", "cursor position: " + l2);Log.i("Ringtones", "music uri2: " + localUri2);Log.i("Ringtones", "music uri: " + localUri);//set default ringtone
    try {RingtoneManager.setActualDefaultRingtoneUri(getRandom.this, position2, localUri2);} catch (Exception localException) { Log.i("Ringtones", "ERROR: " + "Setting Ringtone"); }
    }
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     
  3. Junior Droid
    r2sjoblom's Avatar
    Member #
    173795
    Join Date
    Feb 2011
    Posts
    10
    Phone
    droid x
    #2
    Got it working, just needed to change my listarray from MediaStore to my original RingtoneManager

    Code:
     
    String[] from = {
    mCursor2.getColumnName(mRingtoneManager2.TITLE_COLUMN_INDEX), mCursor2.getColumnName(mRingtoneManager2.URI_COLUMN_INDEX)}; // get the list items for the listadapter could be TITLE or URI

Sponsors

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Similar Threads

  1. Can anyone confirm free hotspot after root and sqlite hack?
    By eric.scheman in forum Droid RAZR Hacks
    Replies: 39
    Last Post: 01-07-2012, 08:43 PM
  2. .db files/sqlite file opener
    By kyle10 in forum Droid General Discussions
    Replies: 0
    Last Post: 12-09-2011, 06:46 PM
  3. [ROM] PlainJane Froyo for Incredible 2 (Stock, root, busybox, sqlite)
    By SHAKE_JONES in forum Droid Incredible 2 Roms
    Replies: 0
    Last Post: 07-10-2011, 01:26 PM
  4. Looking for a Database.
    By smeghead in forum Droid X General Discussions
    Replies: 3
    Last Post: 03-07-2011, 08:45 AM
  5. sqlite on droid?
    By pandroid in forum Droid General Discussions
    Replies: 0
    Last Post: 01-03-2010, 11:44 PM

Search tags for this page

droid database ringtone

,

droid x sqlite

,

how can i see the sqlite database in droid x

,

sqlite droid razr

,

what permissions need to be set in android to use sql

Click on a term to search our site for related topics.

Tags for this Thread