Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:00:14+00:00 2026-05-27T04:00:14+00:00

I’ve got several problems and I’m starting to wonder if my path is correct…

  • 0

I’ve got several problems and I’m starting to wonder if my path is correct…

I would like to make a list of the most often used appliactions based on time scheduled measurments of processor usage. I know how to get usage statistics and processes names, I know how to connect it with apps names and icons. What I don’t know is what to do next.

My idea was to create two tables: PROCESSES AND PROCESS_STATS, store all the information in the database and provide ContentProvider linked with SimpleCursorAdapter. In my opinion it’s the cleaniest solution when working with SQLiteDB on Android. Don’t bother counting effects into some “real” statistics, it’s not the case here.

Problems:

  1. I can’t create the table with blob in it. Code in listing 1 does not work. When i try to read from table (using the code from Listing 2) I get java.lang.IllegalArgumentException: column 'app_icon' does not exist. There are no errors in LogCat while creating the db.
  2. Storing icons (bitmaps) in the db is not a very good design pattern. However, I like the simplicity of my solution: ContentProvider, SimpleCursorAdapter and Fragments do all the background work for me. If I’d like to store icons on SD i would have much more work, especially with the final list of apps. What are the other ways to do this painlessly?

Listing 1:

CREATE TABLE processes
    (_id INTEGER PRIMARY KEY AUTOINCREMENT, 
    name TEXT NOT NULL, 
    app_name TEXT, 
    app_icon BLOB); 

CREATE TABLE process_stats 
    (_id INTEGER PRIMARY KEY AUTOINCREMENT, 
    process_id INTEGER NOT NULL, 
    FOREIGN KEY(process_id) REFERENCES processes(_id), 
    value INTEGER NOT NULL, 
    measurment_date INTEGER NOT NULL); 

Listing 2:

...
import android.support.v4.widget.SimpleCursorAdapter;
...

public class ProcessesStatsActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Cursor cursor = this.managedQuery(StatsProvider.PROCESSES_CONTENT_URI, null, null, null, null);
        String[] columns = new String[] { StatsCollectorDatabase._PROCESS_APP_ICON, StatsCollectorDatabase._PROCESS_APP_NAME, StatsCollectorDatabase._PROCESS_STAT_VALUE };
        int[] views = new int[] { android.R.id.icon, android.R.id.text1, android.R.id.text2 };      

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this.getApplicationContext(), R.layout.processes_stats_list_item, cursor, columns, views, 0);
        this.setListAdapter(adapter);        

    }

}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:00:15+00:00Added an answer on May 27, 2026 at 4:00 am

    For future visitors:

    I ended up with solution like this:

    I don’t save application info in the database. I have only one table, process_stats, in which I store measurment results. When it comes to view the results, I loop manually through the coursor and count everything I wanted. Next, I load details like app icon and app name and view the list.

    I can paste some sample code here. Comment this answer, if interested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I am trying to render a haml file in a javascript response like so:
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.