Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
AntiWiggin
Mar 8, 2009

5436 posted:

Which IDE do people generally prefer? Eclipse or IntelliJ IDEA?

I loving love IntelliJ IDEA. 12.0 added some much needed features in terms of matching the development capabilities of Eclipse. But it's still missing a few components which make it a deal breaker for me (at my job at least).

1. IntelliJ 12.0 doesn't support certain Lint warnings. For example, if you call a method that was added in one of the newer API's, say API level 14, but you're minSDK
is API level 8, your poo poo will just break on older devices, all without any warnings from IntelliJ. This is the main reason I still use Eclipse.

2. Less importantly, the XML formatting in IntelliJ is balls compared to Eclipse. This can be considered nitpicking but IntelliJ still doesn't support the "official" XML formatting and ordering style for attributes. I guess a lot of people could't give a poo poo but my job is big on maintaining a uniform formatting style. Being able to auto-format with Eclipse is a huge time saver in that regard.

Fortunately for me, both of these features are coming in 12.1. I can't loving wait.

Adbot
ADBOT LOVES YOU

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I tried compiling an older app (it targets API8) today via the command line as per a write-up on the app's Google Code page. Unfortunately, compilation errors out when the build process attempts to call the (I've come to find out) deprecated apkbuilder tool in android-sdk\tools.

What are my options at this point? I'm new to Android dev, let alone command line compiling, so I'm not sure what I can do from here to get the app compiled so I can test it.

Gavinvin
Jan 3, 2013

Ambition is not a dirty word. Piss on compromise. Go for the throat.
I really hate how fragmented android devices are, especially amongst different companies even on the same version of android. I work on an android app for my company and we support android 2.1 and up. Most of our clients are small businesses and naturally want to buy the cheapest devices possible. This ends up with us finding bugs with crazy devices from companies I have never heard of, and it wastes a lot of my time that could be spent developing new features.

Its not always unknown devices that cause me problems though, the Samsung Galaxy Note, a very well known and popular device. Gave us a massive headache because if you decided to put a value into one input box, and then quickly move to the next, it would decide to put the entered value in the second input instead. The only way we could find to fix this was to deliberately do a deferred schedule (i.e. a timer set to 0) just after the user enter input.

On a side note, I have found on my own phone (Samsung Galaxy S II) on ICS, that when using the default mail application, you cant use a email address that contains an apostrophe. I'm pretty sure there probably an exploit there that could be abused with that, but for such an important application, on a well known device, on the most recent OS they provide, to have a simple and common escaping issue with apostrophe's is pretty embarrassing.

kitten smoothie
Dec 29, 2001

Gavinvin posted:

On a side note, I have found on my own phone (Samsung Galaxy S II) on ICS, that when using the default mail application, you cant use a email address that contains an apostrophe. I'm pretty sure there probably an exploit there that could be abused with that, but for such an important application, on a well known device, on the most recent OS they provide, to have a simple and common escaping issue with apostrophe's is pretty embarrassing.

Today I learned apostrophes in email addresses are perfectly valid per RFC822. Hopefully some other day Samsung's developers will.

zeekner
Jul 14, 2007

Karthe posted:

I tried compiling an older app (it targets API8) today via the command line as per a write-up on the app's Google Code page. Unfortunately, compilation errors out when the build process attempts to call the (I've come to find out) deprecated apkbuilder tool in android-sdk\tools.

What are my options at this point? I'm new to Android dev, let alone command line compiling, so I'm not sure what I can do from here to get the app compiled so I can test it.

You can run "android update project" from the command line to update the ant build files for that project. You can also import the project into Eclipse and build it using the export function (right click project -> export -> android).

Just make sure they didn't do any weird customization in the build.xml, it'll get replaced when you run the update.

Doctor w-rw-rw-
Jun 24, 2008

Geekner posted:

You can run "android update project" from the command line to update the ant build files for that project. You can also import the project into Eclipse and build it using the export function (right click project -> export -> android).

Just make sure they didn't do any weird customization in the build.xml, it'll get replaced when you run the update.

I forget the name of the file, but there is a specific XML filename that will add and override goals specified in build.xml, if memory recalls.

Sab669
Sep 24, 2009

edit; Fixed :downs:

Sab669 fucked around with this message at 21:59 on Jan 7, 2013

Sab669
Sep 24, 2009

So this week I'm starting some minor Droid development at work. I'm much more comfortable with C# and I'd really like to use Mono, but I wonder if it's really worth it? Having the company spend $400 for a license, trying to find C# examples of whatever I'm trying to do, etc.

I took a few Java courses in college but I didn't like it very much, never did anything sophisticated at all, just made some really bare-bone command line examples of some OO design patterns that I don't remember what so ever. Is the support for Mono big enough, or should I just tough it up and learn Java?

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Sab669 posted:

So this week I'm starting some minor Droid development at work. I'm much more comfortable with C# and I'd really like to use Mono, but I wonder if it's really worth it? Having the company spend $400 for a license, trying to find C# examples of whatever I'm trying to do, etc.

I took a few Java courses in college but I didn't like it very much, never did anything sophisticated at all, just made some really bare-bone command line examples of some OO design patterns that I don't remember what so ever. Is the support for Mono big enough, or should I just tough it up and learn Java?

How different do you perceive Java being from C#? I thought I was in the iPhone thread at first when I read this. C# is really similar to Java in syntax/style, with most of the divergence being around types and collections, as far as I remember.

Sab669
Sep 24, 2009

It's similar enough, I just dislike Eclipse & Netbeans. I think I'm so skeptical because I only had 1 semester with Java as opposed to an entire year's worth of .NET between C# & ASP.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Is it possible to create a reference to an existing layout file in a specialized layout folder? For example, on the Nexus 7 I want to use a two-column layout when in landscape mode but a single-column phone layout in portrait mode. Can I create a reference to /res/layout/activity_layout.xml in /res/layout-sw600dp-port/ so that I only have to edit one activity_layout.xml file instead of maintaining a copy of it within /res/layout-sw600dp-port/?

Doctor w-rw-rw-
Jun 24, 2008

Karthe posted:

Is it possible to create a reference to an existing layout file in a specialized layout folder? For example, on the Nexus 7 I want to use a two-column layout when in landscape mode but a single-column phone layout in portrait mode. Can I create a reference to /res/layout/activity_layout.xml in /res/layout-sw600dp-port/ so that I only have to edit one activity_layout.xml file instead of maintaining a copy of it within /res/layout-sw600dp-port/?

How SlidingMenu does it is how it's done. (https://github.com/jfeinstein10/SlidingMenu/tree/master/example/res/layout-large-land)

You aren't going to be able to deduplicate the layout code but if you really really need to there is an include tag, I believe. If you have such need for ui reuse consider fragments.

YF-23
Feb 17, 2011

My god, it's full of cat!


I have an issue with parsing text from a webpage. I have a function which reads the contents of a webpage and parses it into a String. I have tested the function in a Java console application and it works fine, so if I do
Java code:
String str = DownloadText("http://pastebin.com/raw.php?i=8aG1dVyS");
System.out.print(str);
it will correctly print on the console "sample text", the contents of the page in this example.

On Android however, doing
Java code:
String str = DownloadText("http://pastebin.com/raw.php?i=8aG1dVyS");
		TextView testview = new TextView(this);
		testview.setText(str);
		ll.addView(testview);
will produce an empty space in the position of the TextView. The issue is not with the TextView itself, as other TextViews work fine, and if I replace setText(str) with setText("stuff") then the given String will be properly displayed. The project's manifest.xml does contain the permission to hook up on the Internet (<uses-permission android:name="android.permission.INTERNET" />).

I have no idea why this is not working and it's quite a roadblock. I really don't have any prior experience to developing on Android so it's very likely I'm missing something that ought to be obvious, but I haven't had any luck in figuring out or finding what is causing the application not to parse, or at least return or display the text from the page.

Tamba
Apr 5, 2010

Are you trying to download something in the main thread? That's not allowed anymore, but it should produce this exception:
https://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

YF-23
Feb 17, 2011

My god, it's full of cat!


That might be it, but in that case this should give me the string I put in the catch block, right?

Java code:
String str = "blah";		
try {str = DownloadText("http://pastebin.com/raw.php?i=ZvBPhbEA");}
catch (NetworkOnMainThreadException e){str = "Network on main thread exception!";}
TextView testview = new TextView(this);
testview.setText(str);
ll.addView(testview);
Because in the end it still comes up blank.

zeekner
Jul 14, 2007

You should use Log.e/Log.w/ect, it makes that sort of testing really easy and unambiguous. I doubt the TextView has anything to do with the problem, I would look at your DownloadText function. Android is a pretty good clone of Java 6, it's not perfect. Some libraries are missing or don't function the exact same way.

Here's a simple GET to String example (using the Apache HTTP and IO libraries):
code:
        StringWriter textBuffer = new StringWriter();
        HttpGet get = new HttpGet(location);
        HttpResponse response = httpClient.execute(get);
        HttpEntity result = response.getEntity();
        if(result != null){
            InputStream input = result.getContent();
            IOUtils.copy(input,textBuffer);
            IOUtils.closeQuietly(input);
        }
	Log.d("MyApp", "Result: "+textBuffer.toString());
You can strip out the Apache HTTP libs and just use the URL.openStream() function:
code:
        StringWriter textBuffer = new StringWriter();
	URL dest = new URL("http://pastebin.com/raw.php?i=ZvBPhbEA");
        InputStream get = dest.openStream();
        IOUtils.copy(get, textBuffer);
        IOUtils.closeQuietly(input);
	Log.d("MyApp", "Result: "+textBuffer.toString());

it is
Aug 19, 2011

by Smythe
Maybe it's just because I'm trying to learn how to integrate Facebook into Android before becoming fluent in Android, but figuring out exactly HOW Facebook wants you to authenticate is extremely frustrating. This code (called from my MainActivity)

code:
Session s = new Session.Builder(this).setApplicationId(APP_ID).build();
s.openForRead(new Session.OpenRequest(this));
generates all this stack trace:

code:
02-06 08:18:27.923: E/AndroidRuntime(789): FATAL EXCEPTION: main
02-06 08:18:27.923: E/AndroidRuntime(789): java.lang.RuntimeException: Unable to resume activity {com.hrzntl/com.facebook.LoginActivity}: java.lang.NullPointerException
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.os.Looper.loop(Looper.java:137)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at java.lang.reflect.Method.invokeNative(Native Method)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at java.lang.reflect.Method.invoke(Method.java:511)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at dalvik.system.NativeStart.main(Native Method)
02-06 08:18:27.923: E/AndroidRuntime(789): Caused by: java.lang.NullPointerException
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.LoginActivity$2.onBackgroundProcessingStarted(LoginActivity.java:76)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.notifyBackgroundProcessingStart(AuthorizationClient.java:384)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.access$0(AuthorizationClient.java:382)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient$GetTokenAuthHandler.tryAuthorize(AuthorizationClient.java:509)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:209)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:188)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:116)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:97)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at com.facebook.LoginActivity.onResume(LoginActivity.java:113)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.Activity.performResume(Activity.java:5182)
02-06 08:18:27.923: E/AndroidRuntime(789): 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
02-06 08:18:27.923: E/AndroidRuntime(789): 	... 12 more
WHY

Doctor w-rw-rw-
Jun 24, 2008

it is posted:

Maybe it's just because I'm trying to learn how to integrate Facebook into Android before becoming fluent in Android, but figuring out exactly HOW Facebook wants you to authenticate is extremely frustrating. This code (called from my MainActivity)

WHY

Called from where in your MainActivity?

it is
Aug 19, 2011

by Smythe
onCreate

Doctor w-rw-rw-
Jun 24, 2008

it is posted:

onCreate

So you're creating another activity before one has had the chance to finish onCreate/onStart/onResume. This might not be a problem but it wouldn't hurt to check your assumptions. I would try creating a test button or menu that triggers the same function on that screen, then see if the same error is produced.

it is
Aug 19, 2011

by Smythe
Thanks for getting back to me.

I pulled it out into another method and created a button to execute it. Same error.

Doctor w-rw-rw-
Jun 24, 2008
Hmm, I can't really say for sure. Perhaps you're missing an argument somewhere. Whatever's happening, it's obviously expecting some data that ain't there.

Above Our Own
Jun 24, 2009

by Shine
I'm looking to develop in .NET for android. Is Xamarin's Mono for Android the most feature complete solution? I'm really wanting to spend as little time as possible porting.

I'm also doing a little XNA development on the side, and it would be nice to port this over to Android as well. I understand ExEn runs on top of Xamarin's platform, are there other options for porting XNA to android? Again, I really want to avoid having to write platform-specific code as much as possible and I'm willing to pay for that convenience.

Doctor w-rw-rw-
Jun 24, 2008

Above Our Own posted:

I'm looking to develop in .NET for android. Is Xamarin's Mono for Android the most feature complete solution? I'm really wanting to spend as little time as possible porting.
There are other solutions for .NET on Android? News to me.

Above Our Own posted:

I'm also doing a little XNA development on the side, and it would be nice to port this over to Android as well. I understand ExEn runs on top of Xamarin's platform, are there other options for porting XNA to android? Again, I really want to avoid having to write platform-specific code as much as possible and I'm willing to pay for that convenience.
If you want some sort of UI framework with the same abstraction across platforms, unless I've forgotten something, Xamarin isn't that. It won't save you from writing platform-specific code, it'll save you from writing Java code. I've never heard of ExEn, then again, I've never writing anything on the CLR. So I guess just use ExEn on top of Mono for Android.

Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

it'll save you from writing Java code.

This sounds worth it.

jkyuusai
Jun 26, 2008

homegrown man milk
I've had to rediscover this for the third time or so, so I'm documenting it here.

How to attach Source/Javadocs in Eclipse for those pesky jars in your libs folder
http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder

Two things to watch out for:
Stick the sources and docs in a sub folder in libs (like /libs/docs) so that they're ignored and not bundled with your apk.
The properties file has the same exact name as the jar including the .jar extension with a .properties tagged on the end. (gson.jar = gson.jar.properties)

How to attach Android Sources in Eclipse
Up to API 14 - Install Android Sources plugin from this update site and restart Eclipse - http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/
More info here - http://code.google.com/p/adt-addons/

Sources for 15 and up - They're included as part of the SDK package, but you still have to link them in Eclipse. Make sure you downloaded the source through the SDK manager, then F3 on something and hit the Attach Source button. Select External Folder, and browse to the sources folder, highlight the proper android-** folder inside and hit open. Boom! Maybe restart if it's misbehaving.

Pseudo-God
Mar 13, 2006

I just love oranges!
If I wanted to program a simple roulette wheel or audio visualizer(just bars), do I have to use OpenGL, or is the canvas view suitable?

zeekner
Jul 14, 2007

Pseudo-God posted:

If I wanted to program a simple roulette wheel or audio visualizer(just bars), do I have to use OpenGL, or is the canvas view suitable?

If it's just 2d and you won't need to animate more than 20fps, you can try a SurfaceView. Look at the LunarLander example code to see how it's implemented (get it here). It'll let you run a secondary thread to animate the view.

If you run into performance issues, you can try to swap that for a GLSurfaceView. If you need more performance than that you'll want to look into the NDK+opengl.

You could run a custom View and just override onDraw, but that method has a lot of limitations (especially for animation). You'll have to call invalidate() every time you want to refresh. Those invalidate calls are processed on a queue, so it's can get choppy if you're trying to animate motion.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
So I've been teaching an intro CS class using Android for the past year, and this semester I'm finally upgrading all my assignments' target SDKs from 2.2 to 4.0, while retaining as much compatibility as possible with other devices.

One change I'm making is having students to more with action bars. So, I've created a menu that has 5 items, set showAsAction="always" on all of them. Overrode onCreateOptionsMenu to inflate it in my activity. On a 4.0 emulator, they all show up like I'd expect, and clicking them does the right thing.

On a 2.2-2.3 emulator or device, the menu is loaded and appears properly when I click the Menu button, but clicking the items doesn't do anything. The menu doesn't even get dismissed. I tossed some logging statements in there, and onOptionsItemSelected is never being called. Even setting an onMenuItemClicked handler on the items themselves doesn't change anything.

Has anyone seen this kind of behavior before? I'm not sure what's going on, and Googling has been futile so far.

EDIT: I'm NOT using ActionBarSherlock or anything like that. Everything is standard Android APIs, and I'd rather not bring in third party libraries.

Flobbster fucked around with this message at 03:18 on Feb 21, 2013

it is
Aug 19, 2011

by Smythe
Are you really teaching an intro CS class with Android? That sounds horrible.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

it is posted:

Are you really teaching an intro CS class with Android? That sounds horrible.

I mean I've heard arguments against Java as a teaching language, but "not-quite-Java" with weird Android crap on top?

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
By "intro" I don't mean a first-semester CS course. It's Intro to Software Design and Data Structures, so they already have plenty of experience with the basics of Java and can move on to more advanced stuff.

We've developed some nice abstractions for them to use that get rid of a lot of the Android grunt-work, inspired by and stealing/improving ideas from frameworks like Roboguice, but I don't want to derail the thread talking about that -- unless people are interested :v: It works better than it might sound at first, though.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Is it just me or is Eclipse terrible for debugging? I get an error like this in LogCat and I'm left feeling as though there should be more information attached to it to help me identify which part of the cited line is faulty:
code:
02-22 08:50:32.832: E/AndroidRuntime(3005): Caused by: java.lang.NullPointerException
02-22 08:50:32.832: E/AndroidRuntime(3005): at com.example.testapp.FragmentSearch.onCreateView(FragmentSearch.java:59)
The error points to this line of code:
Java code:
db = new DBHelper(getView().getContext());
According to the error, db or getView().getContext() could be the problem. Based on my experience, I'm probably using getView().getContext() incorrectly, but you wouldn't know it just by looking at the LogCat error output. Having done a few pet projects with C# in VS before, Eclipse's debugging feels lackluster. Am I just not using it correctly? Are there some better tools or settings I can implement that would improve the quality of LogCat's error logs?

And would getView().getContext() return null from within a fragment? I'm trying to pass along the app's context to the helper class from within a fragment that will display the results of a SQL query.

Sereri
Sep 30, 2008

awwwrigami

Karthe posted:

Is it just me or is Eclipse terrible for debugging? I get an error like this in LogCat and I'm left feeling as though there should be more information attached to it to help me identify which part of the cited line is faulty:
code:
02-22 08:50:32.832: E/AndroidRuntime(3005): Caused by: java.lang.NullPointerException
02-22 08:50:32.832: E/AndroidRuntime(3005): at com.example.testapp.FragmentSearch.onCreateView(FragmentSearch.java:59)
The error points to this line of code:
Java code:
db = new DBHelper(getView().getContext());
According to the error, db or getView().getContext() could be the problem. Based on my experience, I'm probably using getView().getContext() incorrectly, but you wouldn't know it just by looking at the LogCat error output. Having done a few pet projects with C# in VS before, Eclipse's debugging feels lackluster. Am I just not using it correctly? Are there some better tools or settings I can implement that would improve the quality of LogCat's error logs?

And would getView().getContext() return null from within a fragment? I'm trying to pass along the app's context to the helper class from within a fragment that will display the results of a SQL query.

If that is the line, getView returns null and you try to call getContext on null which causes the NPE.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Sereri posted:

If that is the line, getView returns null and you try to call getContext on null which causes the NPE.
What's the proper way to pass along an app's context to a function call from within a fragment? I'm using android-sqlite-asset-helper and need to pass one along to the database helper class when I open the database:

Java code:
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		// Specify the fragment layout file for this fragment class
		View view = inflater.inflate(R.layout.fragment_search, container, false);
		
		// Load JMDict
		db = new DBHelper(getView().getContext());
		
		return view;
	}

zeekner
Jul 14, 2007

getView() is null until you return from onCreateView(). The view you create there is the one that getView returns. Use getActivity to get a context.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Salvador Dalvik posted:

getView() is null until you return from onCreateView(). The view you create there is the one that getView returns. Use getActivity to get a context.
That makes so much sense, why did that never dawn on me? That's not the first time I've made that mistake, and it probably won't be the last :downsgun:

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Is a ContentProvider necessary when I'm just working with internal SQLite databases? I'm learning about them now and am left wondering if implementing one would be overkill; all I want to do is move database queries into a separate thread so the app won't hang. Right now I'm only querying static databases, though I will eventually implement another database that will be populated with user-generated content produced from within the app. I want to handle all of the database-related stuff in a database helper class, but everything I've read about introducing threading into the process points me to implementing a CP.

If ContentProviders are something I need to learn if I'm going to be working with SQLite, then can someone help me understand how to best craft URI's? I've skimmed a few ContentProvider tutorials and still can't wrap my head around how I'm supposed to craft URI's for my various use cases. I'm afraid I'll gently caress up and create a CP that's too limited in scope (or go the other way and set up too many URI's) and that'll force me to go back and rewrite large sections of code.

Doctor w-rw-rw-
Jun 24, 2008

Karthe posted:

Is a ContentProvider necessary when I'm just working with internal SQLite databases? I'm learning about them now and am left wondering if implementing one would be overkill; all I want to do is move database queries into a separate thread so the app won't hang. Right now I'm only querying static databases, though I will eventually implement another database that will be populated with user-generated content produced from within the app. I want to handle all of the database-related stuff in a database helper class, but everything I've read about introducing threading into the process points me to implementing a CP.

If ContentProviders are something I need to learn if I'm going to be working with SQLite, then can someone help me understand how to best craft URI's? I've skimmed a few ContentProvider tutorials and still can't wrap my head around how I'm supposed to craft URI's for my various use cases. I'm afraid I'll gently caress up and create a CP that's too limited in scope (or go the other way and set up too many URI's) and that'll force me to go back and rewrite large sections of code.

Skip 'em to start with. If you need to load them asynchronously, there's a loader framework library by CommonsWare for providerless cursors.

Adbot
ADBOT LOVES YOU

A COMPUTER GUY
Aug 23, 2007

I can't spare this man - he fights.

Karthe posted:

Is a ContentProvider necessary when I'm just working with internal SQLite databases? I'm learning about them now and am left wondering if implementing one would be overkill; all I want to do is move database queries into a separate thread so the app won't hang. Right now I'm only querying static databases, though I will eventually implement another database that will be populated with user-generated content produced from within the app. I want to handle all of the database-related stuff in a database helper class, but everything I've read about introducing threading into the process points me to implementing a CP.

If ContentProviders are something I need to learn if I'm going to be working with SQLite, then can someone help me understand how to best craft URI's? I've skimmed a few ContentProvider tutorials and still can't wrap my head around how I'm supposed to craft URI's for my various use cases. I'm afraid I'll gently caress up and create a CP that's too limited in scope (or go the other way and set up too many URI's) and that'll force me to go back and rewrite large sections of code.

Nothing wrong with just calling rawQuery on a SQLiteDatabase object until you start to have more complex queries. The CommonsWare library is ace for asynchronous SQLite queries, but you may not actually need it.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply