-3
Good afternoon to all,
started two weeks ago a sequence of studies on programming for Android. I am studying by this book
http://novatec.com.br/livros/googleand/sumario9788575221860.pdf
bought it a while ago and thank God I finally got on page 341 which is database.
has a class called car, I understand object orientation, but I’ve never seen such a strange class as this
package com.example.googleplay.model;
import java.net.URI;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;
public class Carro {
public static String[] colunas = new String[] { Carros._ID, Carros.NOME,
Carros.PLACA, Carros.ANO };
public static final String AUTHORITY = "com.example.googleplay.model.carro";
public long id;
public String nome;
public String placa;
public int ano;
public Carro() {
}
public Carro(String nome, String placa, int ano) {
super();
this.nome = nome;
this.placa = placa;
this.ano = ano;
}
public Carro(long id, String nome, String placa, int ano) {
super();
this.id = id;
this.nome = nome;
this.placa = placa;
this.ano = ano;
}
public static final class Carros implements BaseColumns {
private Carros() {
}
}
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
+ "/carros");
public static final String CONTENT_TYPE = "vnd.android.curso.dir/vnd.google.carros";
public static final String CONTENT_ITEM_TYPE = "vnd.android.curso.item/vnd.google.carros";
public static final String DEFAULT_SORT_ORDER = "_id_ASC";
public static final String NOME = "nome";
public static final String ANO = "ano";
public static final String PLACA = "placa";
public static Uri getUriId() {
Uri uriCarro = ContentUris.withAppendedId(Carros.CONTENT_URI, id);
return uriCarro;
}
@Override
public String toString() {
return "Nome: " + nome + ", Placa " + placa + ", Ano " + ano;
}
}
I’ll just comment on the parts that went red.
public static String[] colunas = new String[] { Carros._ID, Carros.NOME,
Carros.PLACA, Carros.ANO };
To exist Carros
there needed to be a class called Carros
, but in the book project there is no class called Carros
, he recognized only _ID
The other weirdest thing is Carros
could see _ID
.
Then I really can’t explain.
This other piece of code was also in red:
public static Uri getUriId() {
Uri uriCarro = ContentUris.withAppendedId(Carros.CONTENT_URI, id);
return uriCarro;
}
What turned red was the CONTENT
.
I understand that it’s complicated to have to help without having access to the book, but even so I posted, I hope to get some help.
our bro! perfect, it worked, thank you very much.
– wladyband