データベースの保存場所がストレージであれば「/data/data/パッケージ名/databases/DB名」
に保存されるのでファイルの存在確認するのが手っ取り早い。
String DB_NAME = "test.db"; File file = new File(context.getDatabasePath(DB_NAME).getPath()); boolean dbExists = file.exists();
String DB_NAME = "test.db"; File file = new File(context.getDatabasePath(DB_NAME).getPath()); boolean dbExists = file.exists();
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
private void showNotifications() {
try {
Object service = getSystemService("statusbar");
if (service != null) {
Method expand = service.getClass().getMethod("expand");
expand.invoke(service);
}
} catch (Exception e) {
}
}
$ heroku create --stack cedar Creating blazing-mist-9962... done, stack is cedar http://blazing-mist-9962.herokuapp.com/ | git@heroku.com:blazing-mist-9962.git
<packaging>war</packaging> ↓変更 <packaging>jar</packaging> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> ↓変更 <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency>
dependenciesの子ノードに下記を追加
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>7.4.5.v20110725</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
</dependency>
build,pluginsの子ノードに下記を追加
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<assembleDirectory>target</assembleDirectory>
<programs>
<program>
<mainClass>twitter4j.examples.signin.StartServer</mainClass>
<name>webapp</name>
</program>
</programs>
</configuration>
</execution>
</executions>
</plugin>
package twitter4j.examples.signin;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class StartServer {
public static void main(String[] args) throws Exception {
Server server = new Server(Integer.valueOf(System.getenv("PORT")));
WebAppContext context = new WebAppContext("src/main/webapp", "/");
context.setDescriptor("WEB-INF/web.xml");
server.setHandler(context);
server.start();
server.join();
}
}
web: sh target/bin/webapp
$ cd プロジェクトディレクトリ $ git init $ git add . $ git commit -m "Generate twitter app." $ git remote add heroku git@heroku.com:blazing-mist-9962.git $ git push heroku master
$ heroku open